7.3.6. MdoModel

class mindoptpy.MdoModel

Bases: object

This object implements the data structure to hold an optimization model.

Typical steps to input a column into the optimization model are:

  1. Create a set of empty variable objects by calling mindoptpy.MdoModel.add_var().

  2. Specify the variable’s lower bound, upper bound, and objective coefficients.

  3. Create an empty linear expression object, mindoptpy.MdoExprLinear().

  4. Input a constraint by calling mindoptpy.MdoModel.add_cons().

  5. Optimize the problem by calling mindoptpy.MdoModel.solve_prob().

Attribute
conss_
vars_

Examples

from mindoptpy import *

# Create an empty model.
model = MdoModel()
MDO_INFINITY = MdoModel.get_infinity()

model.set_int_attr("MinSense", 1)
model.set_obj_offset(10.0)

# Add variables.
x1 = model.add_var(0, 10.0, 1, None, "x1", False)
x2 = model.add_var(0, MDO_INFINITY, 1, None, "x2", False)
x3 = model.add_var(0, MDO_INFINITY, 1, None, "x3", False)
x4 = model.add_var(0, MDO_INFINITY, 1, None, "x4", False)

# Add constraints
cons1 = model.add_cons( x1 + x2 + 2 * x3 + 3 * x4 == 1.0, "c1")
cons2 = model.add_cons( x1      -     x3 + 6 * x4 >= 1.0, "c2")

# Set/get elements
model.get_elements([cons1], [x1])
model.set_elements([cons1], [x1], [1.0])
model.delete_elements([cons1], [x1])

# Check model
model.get_expr_linear(cons1)
model.get_col(x1)
model.get_cons(1)
model.get_var(1)

# Set parameters
model.set_int_param("Method", 0)
model.set_int_param("NumThreads", 4)
model.set_int_param("Presolve", 0)
model.set_int_param("SPX/MaxIterations", 400)
model.set_int_param("IPM/MaxIterations", 400)

# Solve and check
model.solve_prob()
model.display_results()
model.get_int_attr("HasSolution")
model.get_int_attr("HasPrimalRay")
model.get_real_attr_index("Activity", 0)
num_iters_spx = model.get_int_attr("SPX/NumIters")
print('The problem took ' + str(num_iters_spx) + ' iterations with simplex method.')
print('x4:', x4.get_real_attr("PrimalSoln"))
print('c1:', model.get_cons(0).get_real_attr("DualSoln"))


# Write model and solution
model.write_prob('model.mps')
model.write_prob('model.lp')
model.write_soln("soln.sol")

# Load model from file
model.free_mdl()
model.create_mdl()
model.read_prob('model.mps')

# Set/get objective
model.set_objs([1.0, 2.0])
model.get_objs()
model.set_max_obj_sense()
model.get_int_attr("MinSense")
model.get_obj_offset()
model.is_max_obj_sense()
model.is_min_obj_sense()

# Set/get model attributes
model.set_int_attr("MinSense", 1)
model.get_int_attr("MinSense")
model.get_int_attr("NumVars")
model.get_int_attr("NumConss")
model.set_real_attr("ObjConst", 10.0)
model.get_real_attr("ObjConst")

lhs_array = [0, -1]
model.set_real_attr_array("LHS", 0, lhs_array)
model.get_real_attr_array("LHS", 0, 2)
rhs_array = [10, 20]
model.set_real_attr_array("RHS", 0, rhs_array)
model.get_real_attr_array("RHS", 0, 2)

colname = "x_2"
model.set_str_attr_index("ColName", 1, colname)
model.get_str_attr_index("ColName", 1)
rowname = "c_0"
model.set_str_attr_index("RowName", 0, rowname)
model.get_str_attr_index("RowName", 0)

is_integer_array = [0, 1]
model.set_int_attr_array("IsInteger", 0, is_integer_array)
model.get_int_attr_array("IsInteger", 0, 2)

# Model deletions
delConss = model.get_conss()
model.delete_conss(delConss)
delVars = model.get_vars()
model.delete_vars(delVars)

# Model free
model.free_mdl()

Methods

add_cons()

Function to introduce a new constraint (row) to the model.

add_cons2()

Function to introduce a new constraint (row) to the model.

add_conss()

Function to add a set of constraints (rows) to the model.

add_var()

Function to introduce a new variable (column) to the model.

add_vars()

Function to introduce a new variable (column) to the model.

create_mdl()

Function to create an internal model.

delete_conss()

This function removes a set of constraints (rows) from the model.

delete_elements()

This function deletes a set of values of all specified elements in the constraint matrix.

delete_vars()

This function removes a set of variables (columns) from the model.

display_results()

Function to display the current solver results.

explain_result()

This function explains the details of a solver result code.

explain_status()

This function explains the details of a solver status code.

compute_iis()

Function to compute an irreduciable infeasible system (IIS).

free_mdl()

Function to free the internal model.

get_col()

This function returns a column object that will hold a set of constraint and coefficient pairs.

get_cons()

This function returns a constraint object.

get_conss()

This function returns a list that will hold all constraint objects.

get_elements()

This function returns a set of values of all specified elements in the constraint matrix.

get_expr_linear()

This function returns a linear expression object that will hold a set of variable and coefficient pairs.

get_infinity()

Function to retrieve the infinity value.

get_int_attr()

Function to retrieve the value of an integer-valued model attribute.

get_int_attr_array()

Function to retrieve the value of the specified array of an integer-valued row/column attribute.

get_int_attr_conss()

Function to retrieve the values of the specified array of an integer-valued row attribute.

get_int_attr_index()

Function to retrieve the value of an integer-valued row/column attribute.

get_int_attr_vars()

Function to retrieve the values of the specified array of an integer-valued column attribute.

get_int_param()

Function to retrieve the value of an integer-valued parameter.

get_obj_offset()

This function returns the objective offset (constant term).

get_objs()

This function returns the values of the objective coefficients.

get_real_attr()

Function to retrieve the value of a real-valued model attribute.

get_real_attr_array()

Function to retrieve the value of a real-valued model attribute.

get_real_attr_conss()

Function to retrieve the values of the specified array of a real-valued row attribute.

get_real_attr_index()

Function to retrieve the value of a real-valued row/column attribute.

get_real_attr_vars()

Function to retrieve the values of the specified array of a real-valued column attribute.

get_real_param()

Function to retrieve the value of a real-valued parameter.

get_result()

Function to retrieve the model result.

get_status()

Function to retrieve the solver status.

get_str_attr_index()

Function to retrieve the value of a string-valued row/column attribute.

get_str_param()

Function to retrieve the value of a string-valued parameter.

get_var()

This function returns a variable object.

get_vars()

This function returns a list that will hold all variable objects.

is_max_obj_sense()

This function returns a flag that specifies if the objective function has a maximization sense.

is_min_obj_sense()

This function returns a flag that specifies if the objective function has a minimization sense.

load_model()

Function to load in the problem.

read_prob()

This function reads an optimization problem from a file.

read_task()

This function loads an optimization model task from a file.

retrieve_task()

This function checks the status of the submitted task, and then retrieve the corresponding optimization result if available.

set_elements()

This function modifies a set of values of all specified elements in the constraint matrix.

set_int_attr()

Function to change the value of an integer-valued model attribute.

set_int_attr_array()

Function to change the values of the specified array of an integer-valued row/column attribute.

set_int_attr_conss()

Function to change the values of the specified array of an integer-valued row attribute.

set_int_attr_index()

Function to change the value of an integer-valued row/column attribute.

set_int_attr_vars()

Function to change the values of the specified array of an integer-valued column attribute.

set_int_param()

Function to change the value of an integer-valued parameter.

set_max_obj_sense()

This function changes the objective function to a maximization sense.

set_min_obj_sense()

This function changes the objective function to a minimization sense.

set_obj_offset()

This function changes the objective offset (constant term).

set_objs()

This function changes the values of the objective coefficients.

set_real_attr()

Function to change the value of a real-valued model attribute.

set_real_attr_array()

Function to change the value of a real-valued model attribute.

set_real_attr_conss()

Function to change the values of the specified array of a real-valued row attribute.

set_real_attr_index()

Function to change the value of a real-valued row/column attribute.

set_real_attr_vars()

Function to change the values of the specified array of a real-valued column attribute.

set_real_param()

Function to change the value of a real-valued parameter.

set_str_attr_index()

Function to change the value of a string-valued row/column attribute.

set_str_param()

Function to change the value of a string-valued parameter.

solve_prob()

Function to solve the loaded optimization problem.

submit_task()

This function submits an optimization model task to a remote server for optimization.

write_prob()

This function writes an optimization problem to a file.

write_soln()

This function writes an optimization solution to a file.

write_task()

This function writes an optimization task to a file.

add_cons()

Function to introduce a new constraint (row) to the model.

Parameters
  • lhs (float or MdoTempLinear) – The left-hand-side value of the new constraint, or a temporary linear object.

  • rhs (float or str) – The right-hand-side value of the new constraint, or a string for the constraint name.

  • expr (MdoExprLinear) – Expression that holds the new linear constraint. Default is None.

  • name (str) – A string object to hold the column name. Default is "".

Returns

A created constraint object.

Return type

MdoCons

add_cons2()

Function to introduce a new constraint (row) to the model.

Parameters
  • temp (MdoTempLinear) – A temporarly object that holds the new linear constraint.

  • name (str) – A string object to hold the name prefix for the new variables. Default is "".

Returns

A created constraint object.

Return type

MdoCons

add_conss()

Function to add a set of constraints (rows) to the model.

Parameters
  • generator – A generator expression, where each iteration produces a constraint.

  • name (str) – A string object to hold the name prefix for the new variables. Default is "c". The actual name of the new variables will have the following format: "c_index", where index is the constraint index.

Returns

A mindoptpy.MdoTupleList() object that contains the new constraints as values, using the their indices in the model as keys.

Return type

MdoTupleList

add_var()

Function to introduce a new variable (column) to the model.

Parameters
  • lb (float) – A lower bound value for the new variable. Default is 0.0.

  • ub (float) – an upper bound value for the new variable. Default is 1.E+20.

  • obj (float) – An objective coefficient for the new variable. Default is 0.0.

  • col (MdoCol) – A column object that holds the nonzero elements. Default is None.

  • name (str) – A string object to hold the column name. Default is "".

  • is_integer (bint) – A boolean flag that specifies if this is an integer variable. Default is False.

Returns

A created variable object.

Return type

MdoVar

add_vars()

Function to introduce a new variable (column) to the model.

Parameters
  • indices – Indices for accessing the new variables.

  • lb (float) – The lower bound values for the new variables. Default is 0.0.

  • ub (float) – The upper bound values for the new variables. Default is 1.E+20.

  • obj (float) – The objective coefficient for the new variables. Default is 0.0.

  • name (str) – A string object to hold the name prefix for the new variables. Default is "v". The actual name of the new variables will have the following format: "v_index".

  • is_integer (bint) – A boolean flag that specifies if this is an integer variable. Default is False.

Returns

A mindoptpy.MdoTupleList() object that contains the new variables as values, using the provided indices as keys.

Return type

MdoTupleList

conss_
create_mdl()

Function to create an internal model.

delete_conss()

This function removes a set of constraints (rows) from the model.

Parameters

conss (array-like) – A list of constraint objects to delete.

delete_elements()

This function deletes a set of values of all specified elements in the constraint matrix.

Parameters
  • conss (array-like) – A list object that holds the references to the constraints.

  • vars (array-like) – A list object that holds the references to the variables.

delete_vars()

This function removes a set of variables (columns) from the model.

Parameters

vars (array-like) – A list of variable objects to delete.

display_results()

Function to display the current solver results.

explain_result()

This function explains the details of a solver result code. Specifically, if MindOpt fails to optimize the loaded problem to optimality, users may use this function to populate the details of the result code.

Parameters

result (int) – Solver result code to be explained.

Returns

A string that holds the details of the given solver result code.

Return type

str

explain_status()

This function explains the details of a solver status code. Specifically, if MindOpt optimize the loaded problem to successfully, users may use this function to populate the solution status.

Parameters

status (int) – Solver status code to be explained.

Returns

A string that holds the details of the given solver status code.

Return type

str

compute_iis()

This function computes a subsystem that contains at least an IIS (irreduciable infeasible system). The cardinality of the subsystem is supposed to be small. Note that the problem is supposed to be infeasible.

Returns

A tupel that contains two list objects. The first list (resp. second list) object will hold all constraints (res. variables) involved in an IIS.

Return type

A tuple

free_mdl()

Function to free the internal model.

get_col()

This function returns a column object that will hold a set of constraint and coefficient pairs.

Parameters

var (MdoVar) – A variable object.

Returns

A column object that will hold a set of constraint and coefficient paris.

Return type

MdoCol

get_cons()

This function returns a constraint object.

Parameters

i (int) – Row index.

Returns

A constraint object.

Return type

MdoCons

get_conss()

This function returns a list that will hold all constraint objects.

Returns

A list that will hold all constraint objects.

Return type

list

get_elements()

This function returns a set of values of all specified elements in the constraint matrix.

Parameters
  • conss (array-like) – A list object that holds the references to the constraints.

  • vars (array-like) – A list object that holds the references to the variables.

Returns

A list object that will hold the nonzero values of all specified elements in the constraint matrix.

Return type

array-like

get_expr_linear()

This function returns a linear expression object that will hold a set of variable and coefficient pairs.

Parameters

cons (MdoCons) – A constraint object.

Returns

A linear expression object that will hold a set of variable and coefficient paris.

Return type

MdoExprLinear

static get_infinity()

Function to retrieve the infinity value.

Returns

Infinity value.

Return type

float

get_int_attr()

Function to retrieve the value of an integer-valued model attribute.

Parameters

att (str) – The integer-valued model attribute.

Returns

The current value.

Return type

int

get_int_attr_array()

Function to retrieve the value of the specified array of an integer-valued row/column attribute.

Parameters
  • att (str) – An integer-valued row/column attribute.

  • bgn (int) – Index of the first element to access.

  • len (int) – Number of elements to access.

Returns

An array that holds the current values of the specified array of the attribute.

Return type

array-like

get_int_attr_conss()

Function to retrieve the values of the specified array of an integer-valued row attribute.

Parameters
  • att (str) – An integer-valued row attribute.

  • vars (array-like) – An array that holds the constraints to access.

Returns

An array that will hold the current values of the specified array of the attribute.

Return type

array-like

get_int_attr_index()

Function to retrieve the value of an integer-valued row/column attribute.

Parameters
  • att (str) – An integer-valued row/column attribute.

  • idx (int) – An index.

Returns

The current value.

Return type

int

get_int_attr_vars()

Function to retrieve the values of the specified array of an integer-valued column attribute.

Parameters
  • att (str) – An integer-valued column attribute.

  • vars (array-like) – An array that holds the variables to access.

Returns

An array that will hold the current values of the specified array of the attribute.

Return type

array-like

get_int_param()

Function to retrieve the value of an integer-valued parameter.

Parameters

par (str) – An integer-valued parameter to access.

Returns

The current value of the integer-valued parameter.

Return type

int

get_obj_offset()

This function returns the objective offset (constant term).

Returns

The objective offset (constant term).

Return type

float

get_objs()

This function returns the values of the objective coefficients.

Returns

An array that holds the current values of the objective coefficients.

Return type

array-like

get_real_attr()

Function to retrieve the value of a real-valued model attribute.

Parameters

att (str) – A real-valued model attribute to access.

Returns

The current value of the real-valued model attribute.

Return type

float

get_real_attr_array()

Function to retrieve the value of a real-valued model attribute.

Parameters
  • att (str) – A real-valued model attribute to access.

  • bgn (int) – Index of the first element to access.

  • len (int) – Number of elements to access.

Returns

An array that holds the current values of the specified array of the attribute.

Return type

array-like

get_real_attr_conss()

Function to retrieve the values of the specified array of a real-valued row attribute.

Parameters
  • att (str) – A real-valued row attribute.

  • conss (array-like) – An array that holds the constraints to access.

Returns

An array that will hold the current values of the specified array of the attribute.

Return type

array-like

get_real_attr_index()

Function to retrieve the value of a real-valued row/column attribute.

Parameters
  • att (str) – A real-valued row/column attribute to access.

  • idx (int) – An index.

Returns

The current value of the real-valued array attribute.

Return type

float

get_real_attr_vars()

Function to retrieve the values of the specified array of a real-valued column attribute.

Parameters
  • att (str) – A real-valued column attribute.

  • vars (array-like) – An array that holds the variables to access.

Returns

An array that will hold the current values of the specified array of the attribute.

Return type

array-like

get_real_param()

Function to retrieve the value of a real-valued parameter.

Parameters

par (str) – A real-valued parameter to access.

Returns

The value of the real-valued parameter.

Return type

float

get_result()

Function to retrieve the model result.

Returns

Model result code.

Return type

int

Returns

Explanation of the model result code.

Return type

str

get_status()

Function to retrieve the solver status.

Return status_code

Solver status code.

Return type

int

Return status_msg

Explanation of the solver status code.

Return type

str

get_str_attr_index()

Function to retrieve the value of a string-valued row/column attribute.

Parameters
  • att (str) – A string-valued row/column attribute.

  • idx (int) – An index.

Returns

The current value.

Return type

str

get_str_param()

Function to retrieve the value of a string-valued parameter.

Parameters

par (str) – A string-valued parameter to access.

Returns

The current value of the string-valued parameter.

Return type

str

get_var()

This function returns a variable object.

Parameters

j (int) – Column index.

Returns

A variable object.

Return type

MdoVar

get_vars()

This function returns a list that will hold all variable objects.

Returns

A list that will hold all variable objects.

Return type

list

is_max_obj_sense()

This function returns a flag that specifies if the objective function has a maximization sense.

Returns

A boolean flag that specifies if the objective function has a maximization sense.

Return type

bint

is_min_obj_sense()

This function returns a flag that specifies if the objective function has a minimization sense.

Returns

A boolean flag that specifies if the objective function has a minimization sense.

Return type

bint

load_model()

Function to load in the problem.

Parameters
  • num_cols (int) – Number of columns (variables).

  • num_rows (int) – Number of rows (constraints).

  • bgn (list) – An integer array that defines the beginning index of a CSC (compressed sparse column) matrix. Here bgn must have num_cols + 1 elements; as a result the length of the last column is bgn[num_cols] - bgn[num_cols - 1].

  • indices (list) – An integer array that defines the column index of nonzero elements in the CSC matrix.

  • values (list) – A real array that defines the values of nonzero elements in the CSC matrix.

  • lbs (list) – A real array that holds the lower bounds of variables. Default is None; in this case a 0 value will be used as the default value for all lower bounds.

  • ubs (list) – A real array that holds the upper bounds of variables. Default is None; in this case an infinity value will be used as the default value for all upper bounds.

  • objs (list) – A real array that holds the linear objective coefficient. Default is None; in this case a 0 value will be used as the default value for all objective coefficients.

  • are_integers (list) – A flag array that specifies if a variable is an integer variable or not. Default is None; in this case all variables will be treated as continuous variables.

  • obj_const (float) – The objective offset. Default is 0.0.

  • is_min (bint) – A boolean flag to specify if the objective function has a minimization sense. Default is True.

  • lhss (list) – A real array that holds the lower bounds (LHS-values) of constraints. Can be None; in this case a minus infinity value will be used as the default value for all lower bounds.

  • rhss (list) – A real array that holds the upper bounds (RHS-values) of constraints. Can be None; in this case an infinity value will be used as the default value for all upper bounds.

  • col_names (list) – A string array that holds the column (variable) names. Default is None.

  • row_names (list) – A string array that holds the row (constraint) names. Default is None.

Note

Here the constraint matrix is is specified with standard compressed sparse column (CSC) matrix that includes column starts (bgn), row indices (indices), and nonzero elements (values). Note that bgn must have num_cols + 1 elements, as a result, the length of the last column is bgn[num_cols] - bgn[num_cols - 1].

read_prob()

This function reads an optimization problem from a file. Note that the type of the inputted model is determined by the file suffix. Valid suffixes are .mps or .lp.

Parameters

filename (str) – A string array that specifies the filename to be read.

read_task()

This function loads an optimization model task from a file. A model task file includes the problem data, parameter settings, and solutions in a binary format.

Parameters
  • filename (str) – A string array that specifies the filename to be read.

  • read_prob (bint) – A boolean flag that specifies if the model shall be loaded. Default is True.

  • read_param (bint) – A boolean flag that specifies if the parameters shall be loaded. Default is True.

  • read_soln (bint) – A boolean flag that specifies if the solution shall be loaded. Default is True.

retrieve_task()

This function checks the status of the submitted task, and then retrieve the corresponding optimization result if available. All possible status values are:

  • “Submitted”

  • “Solving”

  • “Canceled”

  • “Finished”

  • “Failed”

Parameters

job_id (str) – A string that specifies the ID of the submitted job.

Returns

The status of the submitted task.

Return type

str

Returns

A status code that specifies the model status.

Return type

int

Returns

A response code that specifies the optimization status, that is, the response code while calling solve_prob on a remote server.

Return type

int

Returns

A flag that specifies the availability of the solution. If True, user may then use read_task to read the solution file that was saved to the designated location.

Return type

bint

Note

  • The optimization result will be returned only if the submitted task is in a “Finished” status.

  • The token ID and the address of the remote server must be specified before calling this API function.

set_elements()

This function modifies a set of values of all specified elements in the constraint matrix.

Parameters
  • conss (array-like) – A list object that holds the references to the constraints.

  • vars (array-like) – A list object that holds the references to the variables.

  • values (array-like) – A list object that holds the new nonzero values of all specified elements in the constraint matrix.

set_int_attr()

Function to change the value of an integer-valued model attribute.

Parameters
  • att (str) – The integer-valued model attribute.

  • val (int) – A new value.

set_int_attr_array()

Function to change the values of the specified array of an integer-valued row/column attribute.

Parameters
  • att (str) – An integer-valued row/column attribute.

  • bgn (int) – Index of the first element to access.

  • vals (array-like) – An array that stores the new values for the specified array of the attribute.

set_int_attr_conss()

Function to change the values of the specified array of an integer-valued row attribute.

Parameters
  • att (str) – An integer-valued row attribute.

  • vars (array-like) – An array that holds the constraints to access.

  • vals (array-like) – An array that stores the new values for the specified array of the attribute.

set_int_attr_index()

Function to change the value of an integer-valued row/column attribute.

Parameters
  • att (str) – An integer-valued row/column attribute.

  • idx (int) – An index.

  • val (int) – A new value.

set_int_attr_vars()

Function to change the values of the specified array of an integer-valued column attribute.

Parameters
  • att (str) – An integer-valued column attribute.

  • vars (array-like) – An array that holds the variables to access.

  • vals (array-like) – An array that stores the new values for the specified array of the attribute.

set_int_param()

Function to change the value of an integer-valued parameter.

Parameters
  • par (str) – An integer-valued parameter to access.

  • value (int) – A new value for the integer-valued parameter.

set_max_obj_sense()

This function changes the objective function to a maximization sense.

set_min_obj_sense()

This function changes the objective function to a minimization sense.

set_obj_offset()

This function changes the objective offset (constant term).

Parameters

offset (float) – New objective offset (constant term)

set_objs()

This function changes the values of the objective coefficients.

Parameters

or MdoExprLinear (list) – An array that holds the new values for the objective coefficients, or a MdoExprLinear object.

set_real_attr()

Function to change the value of a real-valued model attribute.

Parameters
  • att (str) – A real-valued model attribute to access.

  • val (float) – A new value for the real-valued model attribute.

set_real_attr_array()

Function to change the value of a real-valued model attribute.

Parameters
  • att (str) – A real-valued model attribute to access.

  • bgn (int) – Index of the first element to access.

  • val (array-like) – An array that stores the new values for the specified array of the attribute.

set_real_attr_conss()

Function to change the values of the specified array of a real-valued row attribute.

Parameters
  • att (str) – A real-valued row attribute.

  • vars (array-like) – An array that holds the constraints to access.

  • vals (array-like) – An array that holds the new values for the specified array of the attribute.

set_real_attr_index()

Function to change the value of a reeal-valued row/column attribute.

Parameters
  • att (str) – A real-valued row/column attribute to access.

  • idx (int) – An index.

  • val (float) – A new value.

set_real_attr_vars()

Function to change the values of the specified array of a real-valued column attribute.

Parameters
  • att (str) – A real-valued column attribute.

  • vars (array-like) – An array that holds the variables to access.

  • vals (array-like) – An array that holds the new values for the specified array of the attribute.

set_real_param()

Function to change the value of a real-valued parameter.

Parameters
  • par (str) – A real-valued parameter to access.

  • value (float) – A new value for the real-valued parameter.

set_str_attr_index()

Function to change the value of a string-valued row/column attribute.

Parameters
  • att (str) – A string-valued row/column attribute.

  • idx (int) – An index.

  • val (str) – A new value.

set_str_param()

Function to change the value of a string-valued parameter.

Parameters
  • par (str) – A string-valued parameter to access.

  • value (int) – A new value for the string-valued parameter.

solve_prob()

Function to solve the loaded optimization problem.

submit_task()

This function submits an optimization model task to a remote server for optimization. A model task file includes the problem data, parameter settings, and solutions in a binary format.

Returns

A string that specifies the ID of the submitted job. Users may use this job ID to query the optimization result.

Return type

str

Note

The token ID and the address of the remote server must be specified before calling this API function.

vars_
write_prob()

This function writes an optimization problem to a file. Note that the type of the inputted model is determined by the file suffix. Valid suffixes are .mps or .lp.

Parameters

filename (str) – A string array that specifies the filename for the output.

write_soln()

This function writes an optimization solution to a file. Note that the type of the optimization solution is determined by the file suffix. Valid suffixes are .sol or .bas.

Parameters

filename (str) – A string array that specifies the filename for the output.

write_task()

This function writes an optimization task to a file. A model task file includes the problem data, parameter settings, and solutions in a binary format.

Parameters
  • filename (str) – A string array that specifies the filename for the output.

  • write_prob (bint) – A boolean flag that specifies if the model shall be outputted. Default is True.

  • write_param (bint) – A boolean flag that specifies if the parameters shall be outputted. Default is True.

  • write_soln (bint) – A boolean flag that specifies if the solution shall be outputted. Default is True.