Skip to content

Instantly share code, notes, and snippets.

@braindeaf
Created October 9, 2020 07:08
Show Gist options
  • Save braindeaf/66b391e0f7a7d896a45925c167168498 to your computer and use it in GitHub Desktop.
Save braindeaf/66b391e0f7a7d896a45925c167168498 to your computer and use it in GitHub Desktop.
My First Solver - are you proud of me?
#!/usr/local/bin/python3
from __future__ import print_function
from ortools.linear_solver import pywraplp
t = 'WhatIsX'
s = pywraplp.Solver(t, pywraplp.Solver.GLOP_LINEAR_PROGRAMMING)
x = s.NumVar(0, 1000, 'x')
s.Add(x + 2*x + 3*x + 4*x == 10) # it's almost algebraic syntax
s.Solve()
print(x.SolutionValue())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment