fix examples to work with python3, linear_solver is not yet working; tested with python 3.5

This commit is contained in:
Laurent Perron
2015-12-09 06:23:06 -08:00
parent de9a5b6653
commit 7c58ce62f9
5 changed files with 42 additions and 42 deletions

View File

@@ -56,8 +56,8 @@ def RunIntegerExampleCppStyleAPI(optimization_problem_type):
def SolveAndPrint(solver, variable_list):
"""Solve the problem and print the solution."""
print 'Number of variables = %d' % solver.NumVariables()
print 'Number of constraints = %d' % solver.NumConstraints()
print('Number of variables = %d' % solver.NumVariables())
print('Number of constraints = %d' % solver.NumConstraints())
result_status = solver.Solve()
@@ -68,17 +68,17 @@ def SolveAndPrint(solver, variable_list):
# GLOP_LINEAR_PROGRAMMING, verifying the solution is highly recommended!).
assert solver.VerifySolution(1e-7, True)
print 'Problem solved in %f milliseconds' % solver.wall_time()
print('Problem solved in %f milliseconds' % solver.wall_time())
# The objective value of the solution.
print 'Optimal objective value = %f' % solver.Objective().Value()
print('Optimal objective value = %f' % solver.Objective().Value())
# The value of each variable in the solution.
for variable in variable_list:
print '%s = %f' % (variable.name(), variable.solution_value())
print('%s = %f' % (variable.name(), variable.solution_value()))
print 'Advanced usage:'
print 'Problem solved in %d branch-and-bound nodes' % solver.nodes()
print('Advanced usage:')
print('Problem solved in %d branch-and-bound nodes' % solver.nodes())
def Announce(solver, api_type):