8.6.1. Global functions

MinOpt Python SDK global functions.

Methods

models()

Return all current instantiated models except those in the user’s data structure

disposeDefaultEnv()

Releases the resources associated with the default Environment

multidict()

Split a dictionary into multiple dictionaries

paramHelp()

Get help documentation for Mindopt parameters

quicksum()

Quickly sum to get an expression

read()

Read a model from a file

readParams()

Read parameter settings from a file

resetParams()

Set all parameters to their default values

setParam()

Set the value of a parameter

system()

Start a process in shell to execute commands or scripts

writeParams()

Writes the parameter settings of the current default Environment to a file

version()

Retrieve version numbers of MindOpt

models()

Return all current instantiated models except those in the user’s data structure

Returns

List of instantiated models

disposeDefaultEnv()

Releases the resources associated with the default Environment.

Note

When you need to use the default Environment again after you disposed it, Environment will be automatically created again

multidict(d)

Split a dictionary into multiple dictionaries

Parameters

d – Dictionary to be split

Returns

A list containing all keys and multiple multidict

example:

(keys, dict1, dict2) = multidict ({
    'keye': [1, 2],
    'key2': [1, 3],
    'key3': [1, 4]})
paramHelp(paramname)

Get help documentation for Mindopt parameters

Parameters

paramname – The name of the parameter for help

example:

paramHelp()
paramHelp("MaxTime")
paramHelp("IPM*")

Note

Argument paramname can contain ‘*’ and ‘?’ wildcard characters

quicksum(li)

Quickly sum to get an expression

Parameters

li – List of terms

Returns

A LinExpr or QuadExpr, depending on whether there is a quadratic term.

example:

m = Model()
x = m.addVar()
y = m.addVar()
linExpr = quicksum([1 * x, 2 * y])
quadExpr = quicksum([1 * x * x, 2 * x * y])
read(filename, env=None)

Read a model from a file

Parameters
  • filename – The file name that contains the model. The format of the model is determined by the suffix of the file name, such as ‘.mps’, ‘.lp’, ‘.qps’, ‘.dat-s’. If file is compressed, filename requires a suffix to indicate its compression type, such as ‘.gz’, ‘.bz2’.

  • env=None – optional. set it if you want to use a custom Environment

Returns

Model instance read from file

readParams(filename)

Read parameter settings from a file

Parameters

filename – The file name of the parameter settings, valid suffix is ‘.prm’.

example:

readParams("settings.prm")

Note

This modification applies to all models that can be returned from models()

resetParams()

Set all parameters to their default values.

example:

resetParams()

Note

This modification applies to all models that can be returned from models()

setParam(paramname, paramvalue)

Set the value of a parameter

Parameters
  • paramname – The name of the parameter to be set.

  • paramvalue – Parameter value

example:

setParam("MaxTime", 10)
setParam("MaxTi*", 10)
setParam("MaxTi*", "default")

Note

  1. This modification applies to all models that can be returned from models().

  2. Parameter names can contain ‘*’ and ‘?’ wildcard. If more than one parameter name is matched, the parameter value is not modified.

  3. When the parameter value is ‘default’, you can reset the parameter to its default value.

system(command)

Start a process in shell to execute commands or scripts

Parameters

command – The list of command or script parameters to be executed.

example:

system("echo 'mindopt'")
writeParams(filename)

Writes the parameter settings of the current default Environment to a file.

Parameters

filename – The name of the file.

example:

writeParams("settings.prm")

Note

If the current default Environment is released, the method reports an error.

version()

Retrieve version numbers of MindOpt. Method returns a tuple with 3 numbers:

  • major version number

  • minor version number

  • technical version number