FICO
FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserPrevious exampleNext example

Repeatedly solving a problem

Description
Reads a problem, solves it, then adds a constraint and re-solves it

Further explanation of this example: 'Xpress Python Reference Manual'

Resolve_python.zip[download all files]

Source Files





example_resolve.py

#
# test-resolve.py
#
# Reads a problem solves it, then adds a constraint and re-solves it
#

from __future__ import print_function

import xpress

p = xpress.problem()

p.read("example.lp")
p.solve()
print("solution of the original problem: ", p.getVariable(), "-->",
      p.getSolution())

x = p.getVariable()
p.addConstraint(xpress.Sum(x) <= 1.1)
p.solve()
print("New solution: ", p.getSolution())

Back to examples browserPrevious exampleNext example