Initializing help system before first use

Using the tuner functions in the Python interface


Type: Programming
Rating: 2 (easy-medium)
Description: Read a MIPLIB2010 problem instance, then apply the Optimizer's tuner both with default tuner method and with a user-defined method file.
File(s): tuner_example.py


tuner_example.py
import xpress as xp

# Creates a problem and read a MIPLIB2010 instance

p = xp.problem()
p.read('miplib-rndinst.mps.gz')

# Create a file default-MIP.xtm with the tuner options that are tested
# by default by the tuner. The file has the following format: a
# section with controls that are applied to each tuner run
# ("FIXED-CONTROLS") and a set of controls that are tested
# independently by the tuner ("TUNABLE-CONTROLS"). Tunable controls
# have each one or more value that the tuner will test, first
# independently and then in combination with others.
#
# FIXED-CONTROLS
#   OUTPUTLOG            = 1
#   XSLP_POSTSOLVE       = 1
# TUNABLE-CONTROLS
#   BRANCHDISJ           = 0
#   COVERCUTS            = 0, 2, 20
#   CUTFACTOR            = 0.5, 1, 5
#   CUTFREQ              = 2
#
# ... and others. The file is written AFTER reading in the problem in order
# for the optimizer to recognize that it is a MIP.

p.tunerwritemethod('default-MIP.xtm')

# Set the total amount of time the tuner can spend in tuning
# (tunermaxtime) and the time limit for each run.
p.controls.tunermaxtime = 100
p.controls.timelimit = 10

# Tune the optimizer on the problem
p.tune('g')

# Now try tuning on a different tuner method: the file mymethod.xtm
# contains slightly different combination of controls and values, and
# the tuner will test different combinations this way. Note that the
# output will show that the Optimizer finds old tuner runs and will
# use the relative information
p.tunerreadmethod('mymethod.xtm')
p.tune()

# Finally, before solving the problem, increase the time limit.
p.controls.timelimit = 1000

p.optimize()

© 2001-2024 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.