Linear Optimization

Linear optimization (or linear programming) is the name given to computing the best solution to a problem modeled as a set of linear relationships. These problems arise in many scientific and engineering disciplines. (The word "programming" is a bit of a misnomer, similar to how "computer" once meant "a person who computes." Here, "programming" refers to the arrangement of a plan, rather than programming in a computer language.)

Google provides three ways to solve linear optimization problems: the open-source library Glop, the Linear Optimization add-on for Google Sheets, and the Linear Optimization Service in Google Apps Script.

  • Glop is Google's in-house linear solver, available as open source. You can access Glop through the OR-Tools linear solver wrapper, which is a wrapper for Glop, as well as several other third-party linear optimization solvers. To learn how solve a simple linear problem using Glop in all of the supported languages, see Getting Started with OR-Tools.
  • The Linear Optimization add-on for Google Sheets lets you solve linear optimization problems by entering variables and constraints in a spreadsheet. Under the hood, it uses Apps Script's Linear Optimization Service.
  • The Linear Optimization Service in Google Apps Script lets developers make function calls to solve linear optimization problems. It relies on Glop for pure linear-optimization problems where all variables can take on real values. If any variables are constrained to be integers, the service uses SCIP, from Zuse-Institut Berlin.

Note that the second and third options don't require you to install OR-Tools.