Runs the solver and returns the best solution found.
class LinearOptimizationService method .solve()
LinearOptimizationService is the Apps Script service.
.solve() is the method name you will see after a dot in your code.
What it does
Why it's used
- Run the optimizer and get the best feasible plan.
- Write results back to a sheet for review.
Common errors
- Forgetting parentheses on solve. Write LinearOptimizationService.solve(), not LinearOptimizationService.solve or solve by itself.
- Skipping dots between chained calls. Each step needs a dot, like LinearOptimizationService.solve().
- Adding spaces where they do not belong. Write LinearOptimizationService.solve(), not LinearOptimizationService .solve(), LinearOptimizationService.solve (), or LinearOptimizationService . solve().
- Wrong capitalization. Use LinearOptimizationService and solve, not linearoptimizationservice or solve.
Explore
Related methods
-
.createEngine()
Creates a solver for a linear optimization problem.
-
.addConstraint()
Adds a rule the solution must satisfy.
-
.addVariable()
Adds a decision variable to the optimization model.
More Apps Script
Better Sheets tutorials
No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.