update base libraries; improve sat internals

This commit is contained in:
Laurent Perron
2019-11-25 12:02:25 +01:00
parent e4a73555c4
commit 42676d6535
25 changed files with 205 additions and 84 deletions

View File

@@ -10,7 +10,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Integer programming examples that show how to use the APIs."""
"""MIP example that uses a variable array."""
# [START program]
# [START import]
from __future__ import print_function
@@ -23,7 +23,6 @@ from ortools.linear_solver import pywraplp
def create_data_model():
"""Stores the data for the problem."""
data = {}
# Locations in block units
data['constraint_coeffs'] = [
[5, 7, 9, 2, 1],
[18, 4, -9, 10, 12],
@@ -50,6 +49,7 @@ def main():
solver = pywraplp.Solver('simple_mip_program',
pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)
# [END solver]
# [START variables]
infinity = solver.infinity()
x = {}

View File

@@ -50,20 +50,17 @@ def main():
# [END objective]
# [START solve]
result_status = solver.Solve()
# The problem has an optimal solution.
assert result_status == pywraplp.Solver.OPTIMAL
# The solution looks legit (when using solvers others than
# GLOP_LINEAR_PROGRAMMING, verifying the solution is highly recommended!).
assert solver.VerifySolution(1e-7, True)
status = solver.Solve()
# [END solve]
# [START print_solution]
print('Solution:')
print('Objective value =', solver.Objective().Value())
print('x =', x.solution_value())
print('y =', y.solution_value())
if status == pywraplp.Solver.OPTIMAL:
print('Solution:')
print('Objective value =', solver.Objective().Value())
print('x =', x.solution_value())
print('y =', y.solution_value())
else:
print('The problem does not have an optimal solution.')
# [END print_solution]
# [START advanced]