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

Re-solving problem using the Barrier method's warm start

Solve one problem and use its solution to warm-start the solve of a second, slightly different, problem.

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

Source Files
By clicking on a file name, a preview is opened at the bottom of this page.[download]

# Example of the barstart functionality.
# (C) Fair Isaac Corp., 2020-2021

import xpress as xp

# Read and solve the first problem

ifdisk = True

p = xp.problem()'d2q06c.mps.gz')

p.controls.baralg = 2
p.controls.barstart = 1024
p.controls.crossover = 0


print ('First problem solved with status:', p.getProbStatusString())

if ifdisk:
    p.writeslxsol('mysol.slx', 'd')
    x, s, d, r = [], [], [], []
    p.getlpsol(x, s, d, r)

# Read a slightly modified problem and solve it using the solution of
# p as a warm start.

p2 = xp.problem()'d2q06c_mod.mps.gz')

p2.controls.baralg = 2

# This instructs barrier to use the available solution as warm-start.
p2.controls.barstart = -1

p2.controls.crossover = 0

if ifdisk:
    p2.loadlpsol(x, s, d, r)

# Assign an emphasis to the warm-start (0.85 is the default). With a
# higher value, ther number of barrier iteration is even smaller.
# p2.controls.barstartweight = 0.9


print ('Warm-started problem solved with status:', p2.getProbStatusString())

Back to examples browserPrevious exampleNext example