add a ortools package for python modules; kept compatibility; updated all examples

This commit is contained in:
lperron@google.com
2013-12-24 11:35:01 +00:00
parent a7d29d9fa0
commit 82a815ab65
145 changed files with 245 additions and 218 deletions

View File

@@ -28,7 +28,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys
from linear_solver import pywraplp
from ortools.linear_solver import pywraplp
def main(sol = 'GLPK'):

View File

@@ -47,7 +47,7 @@
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
from collections import defaultdict
#

View File

@@ -64,7 +64,7 @@
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -51,7 +51,7 @@
"""
import string, sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(n=12):

View File

@@ -51,7 +51,7 @@
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#
# Decomposition of alldifferent_except_0

View File

@@ -45,7 +45,7 @@
"""
import sys, string, re
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(problem_str="SEND+MORE=MONEY", base=10):

View File

@@ -31,7 +31,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(cost, rows, cols):

View File

@@ -40,7 +40,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys
from linear_solver import pywraplp
from ortools.linear_solver import pywraplp
def main(sol = 'GLPK'):

View File

@@ -14,7 +14,7 @@
from google.apputils import app
import gflags
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
FLAGS = gflags.FLAGS

View File

@@ -22,7 +22,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys
from linear_solver import pywraplp
from ortools.linear_solver import pywraplp
def main(sol = 'GLPK'):

View File

@@ -49,7 +49,7 @@
import sys
import string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(m=40, n=4):

View File

@@ -36,7 +36,7 @@
import sys
import string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp

View File

@@ -32,7 +32,7 @@
import sys
import string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(num_sol=3):

View File

@@ -43,7 +43,7 @@
import sys
import string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#
# circuit(x)

View File

@@ -37,7 +37,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys, string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -53,7 +53,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(unused_argv):
# Create the solver.

View File

@@ -40,7 +40,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from linear_solver import pywraplp
from ortools.linear_solver import pywraplp
def main(unused_argv):

View File

@@ -38,7 +38,7 @@
"""
import sys
from linear_solver import pywraplp
from ortools.linear_solver import pywraplp
def main(sol = 'GLPK'):

View File

@@ -32,7 +32,7 @@
"""
import sys,string
from collections import *
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -40,7 +40,7 @@
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#
# Global constraint regular

View File

@@ -62,7 +62,7 @@
import sys
import string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(n=6):

View File

@@ -59,7 +59,7 @@
import sys
import string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -38,7 +38,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys, string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(sols=1):

View File

@@ -57,7 +57,7 @@
"""
from google.apputils import app
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(_):

View File

@@ -44,7 +44,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -43,7 +43,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -59,7 +59,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def decreasing(solver, x):

View File

@@ -40,7 +40,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys, string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
# converts a number (s) <-> an array of numbers (t) in the specific base.
def toNum(solver, t, s, base):

View File

@@ -44,7 +44,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp

View File

@@ -46,7 +46,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp

View File

@@ -36,7 +36,7 @@
"""
import sys
from linear_solver import pywraplp
from ortools.linear_solver import pywraplp
def main(sol = 'GLPK'):

View File

@@ -54,7 +54,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(row_sums="", col_sums=""):

View File

@@ -53,7 +53,7 @@
"""
import string, sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#
# Decomposition of modulo constraint

View File

@@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def dudeney(n):
solver = pywrapcp.Solver('Dudeney')

View File

@@ -63,7 +63,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -64,7 +64,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -27,7 +27,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -27,7 +27,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -50,7 +50,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
# Puzzle 1 from

View File

@@ -36,7 +36,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys, string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#

View File

@@ -45,7 +45,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(values, lt):

View File

@@ -25,7 +25,7 @@
"""
import sys
from linear_solver import pywraplp
from ortools.linear_solver import pywraplp
def main(sol = 'GLPK'):

View File

@@ -26,7 +26,7 @@ of the rule.
from google.apputils import app
import gflags
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
FLAGS = gflags.FLAGS

View File

@@ -39,7 +39,7 @@
import sys
import string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -41,7 +41,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -26,7 +26,7 @@
"""
from google.apputils import app
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def BuildPairs(rows, cols):

View File

@@ -17,7 +17,7 @@
from google.apputils import app
from linear_solver import pywraplp
from ortools.linear_solver import pywraplp
def RunIntegerExampleNaturalLanguageAPI(optimization_problem_type):

View File

@@ -27,7 +27,7 @@ jobs. This is called the makespan.
from google.apputils import app
import gflags
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
FLAGS = gflags.FLAGS

View File

@@ -45,7 +45,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -57,7 +57,7 @@
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#
# Ensure that the sum of the segments

View File

@@ -58,7 +58,7 @@
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#
# Ensure that the sum of the segments

View File

@@ -69,7 +69,7 @@
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#
# Ensure that the sum of the segments

View File

@@ -18,7 +18,7 @@
from google.apputils import app
import gflags
from algorithms import pywrapknapsack_solver
from ortools.algorithms import pywrapknapsack_solver
FLAGS = gflags.FLAGS

View File

@@ -22,7 +22,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def knapsack(solver, values, weights, n):
z = solver.IntVar(0, 10000)

View File

@@ -22,7 +22,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys
from linear_solver import pywraplp
from ortools.linear_solver import pywraplp
def main(sol = 'GLPK'):

View File

@@ -47,7 +47,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -47,7 +47,7 @@
import sys
import string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(k=8, num_sol=0):

View File

@@ -37,7 +37,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_cp_solver/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(unused_argv):
# Create the solver.

View File

@@ -26,7 +26,7 @@
"""
import sys
from linear_solver import pywraplp
from ortools.linear_solver import pywraplp
def main(sol = 'GLPK'):

View File

@@ -45,7 +45,7 @@
"""
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -21,7 +21,7 @@
from google.apputils import app
from graph import pywrapgraph
from ortools.graph import pywrapgraph
def RunAssignmentOn4x4Matrix():

View File

@@ -16,7 +16,7 @@
from google.apputils import app
from linear_solver import pywraplp
from ortools.linear_solver import pywraplp
def RunLinearExampleNaturalLanguageAPI(optimization_problem_type):

View File

@@ -24,7 +24,7 @@ distribute().
from google.apputils import app
import gflags
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
FLAGS = gflags.FLAGS

View File

@@ -22,7 +22,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import string, sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(n=4):

View File

@@ -28,7 +28,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import string, sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(n=3):

View File

@@ -42,7 +42,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys
from linear_solver import pywraplp
from ortools.linear_solver import pywraplp
#
# main(n, use_output_matrix)

View File

@@ -33,7 +33,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -48,7 +48,7 @@
"""
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -28,7 +28,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -28,7 +28,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -63,7 +63,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
default_r = 8
default_c = 8

View File

@@ -48,7 +48,7 @@
"""
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -43,7 +43,7 @@
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#

View File

@@ -67,7 +67,7 @@
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#

View File

@@ -67,7 +67,7 @@
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#

View File

@@ -67,7 +67,7 @@
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#

View File

@@ -68,7 +68,7 @@
"""
import sys
import string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(m=3, n=6, minimize_val=0):

View File

@@ -22,7 +22,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(n=8):

View File

@@ -25,7 +25,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys, string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(n=8):

View File

@@ -27,7 +27,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys, string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(n=8, num_sol=0, print_sol=1):

View File

@@ -29,7 +29,7 @@
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
from collections import defaultdict
#

View File

@@ -57,7 +57,7 @@
"""
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def minus(solver, x, y, z):
solver.Add(z == abs(x - y))

View File

@@ -33,7 +33,7 @@
"""
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#
# No overlapping of tasks s1 and s2

View File

@@ -35,7 +35,7 @@
"""
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -63,7 +63,7 @@
import string, sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#
# converts a number (s) <-> an array of integers (t) in the specific base.

View File

@@ -49,7 +49,7 @@
import sys
import string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(show_all_max=0):

View File

@@ -42,7 +42,7 @@
import sys
import string
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -54,7 +54,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -17,16 +17,16 @@
Production planning problem in Google or-tools.
From the OPL model production.mod.
This model was created by Hakan Kjellerstrand (hakank@bonetmail.com)
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys
from linear_solver import pywraplp
from ortools.linear_solver import pywraplp
def main(sol = 'GLPK'):
# Create the solver.
# using GLPK
@@ -65,7 +65,7 @@ def main(sol = 'GLPK'):
inside = [solver.NumVar(0, 10000, 'inside[%i]' % p )
for p in range(num_products)]
outside = [solver.NumVar(0, 10000, 'outside[%i]' % p )
for p in range(num_products)]
for p in range(num_products)]
# to minimize
z = solver.Sum([inside_cost[p] * inside[p] + outside_cost[p] * outside[p]
@@ -93,7 +93,7 @@ def main(sol = 'GLPK'):
print 'outside:', outside[p].SolutionValue(), ' (ReducedCost:', outside[p].ReducedCost(), ')'
print
if __name__ == '__main__':
sol = 'GLPK'
@@ -102,5 +102,5 @@ if __name__ == '__main__':
if sol != 'GLPK' and sol != 'CBC':
print 'Solver must be either GLPK or CBC'
sys.exit(1)
main(sol)

View File

@@ -16,7 +16,7 @@
from google.apputils import app
from graph import pywrapgraph
from ortools.graph import pywrapgraph
def MaxFlow():

View File

@@ -51,7 +51,7 @@
"""
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
default_n = 5
X = 0

View File

@@ -23,7 +23,7 @@ flavors of constraint programming interfaces.
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -38,7 +38,7 @@
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#

View File

@@ -38,7 +38,7 @@
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#

View File

@@ -38,7 +38,7 @@
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
#

View File

@@ -46,7 +46,7 @@
"""
import sys, string, re
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(problem, rows, cols, max_steps):

View File

@@ -45,7 +45,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -29,7 +29,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -60,7 +60,7 @@
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
"""
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main():

View File

@@ -62,7 +62,7 @@
"""
import sys
from constraint_solver import pywrapcp
from ortools.constraint_solver import pywrapcp
def main(singe=0):

Some files were not shown because too many files have changed in this diff Show More