SolveSolution#
- class m4opt.milp.SolveSolution(model, var_value_map, obj, name)[source] [edit on github]#
Bases:
SolveSolutionCreates a new solution object, associated to a a model.
- Parameters:
model – The model to which the solution is associated. This model cannot be changed.
obj – The value of the objective in the solution. A value of None means the objective is not defined at the time the solution is created, and will be set later.
blended_obj_by_priority – For multi-objective models: the value of sub-problems’ objectives (each sub-problem groups objectives having same priority).
var_value_map – a Python dictionary containing associations of variables to values.
name – a name for the solution. The default is None, in which case the solution is named after the model name.
- Returns:
A solution object.
Methods Summary
get_values(var_seq)Get solution values for multidimensional arrays of variables.
Methods Documentation
- get_values(var_seq)[source] [edit on github]#
Get solution values for multidimensional arrays of variables.
Examples
>>> from m4opt.milp import Model >>> m = Model() >>> x = m.continuous_vars((3, 4), ub=42) ✓ adding 12 continuous variables 0:00:00 >>> m.maximize(m.sum(x.ravel())) >>> solution = m.solve() Version identifier: ... >>> solution.get_values(x[0]) array([42., 42., 42., 42.]) >>> solution.get_values(x) array([[42., 42., 42., 42.], [42., 42., 42., 42.], [42., 42., 42., 42.]])