mass.thermo.conc_solver

Module handling optlang.interface.Model for concentration problems.

The purpose of the ConcSolver is to provide an interface to assist with setting up various problems involving optimization-like problems involving metabolite concentrations. Note that all internal solver variables exist in logarithmic space and therefore all associated numerical values are transformed from linear space into log space before being added to the solver. Unless specified otherwise, all numerical solutions will be transformed back into linear space from logspace before being returned.

Upon initialization, a generic problem is created, represented by an optlang.interface.Model. The generic problem includes variables for the metabolite concentration and reaction equilibrium constants, along with thermodynamic constraints for each reaction with the direction of the constraint (i.e. greater/less than) dependent on the sign of the steady state flux.

In addition to creating a generic problem, the ConcSolver has the following functions available to create a specific type of problem:

If custom objectives, constraints and/or variables are to be used with the solver, it is recommended to run one of the above functions first to setup the problem, and then tailor the solver with customizations for that problem.

Notes

  • An optlang.interface.Model represents an optimization problem and contains the variables, constraints, and objectives that make up the problem. See the optlang documentation for more information.

  • All numerical values to be utilized by the solver must be defined. This includes:

Module Contents

Classes

ConcSolver

Class providing an interface for concentration mathematical problems.

Functions

concentration_constraint_matricies(concentration_solver)

Create a matrix representation of the problem.

class mass.thermo.conc_solver.ConcSolver(model, excluded_metabolites=None, excluded_reactions=None, equilibrium_reactions=None, constraint_buffer=0, **kwargs)[source]

Class providing an interface for concentration mathematical problems.

Upon initialization, a generic problem is created, represented by an optlang.Model. The generic problem includes variables for the metabolite concentration and reaction equilibrium constants, along with thermodynamic constraints for each reaction with the direction of the constraint (i.e. greater/less than) dependent on the sign of the steady state flux.

Notes

  • All internal solver variables exist in logarithmic space and therefore all associated numerical values are transformed from linear space into log space before being added to the solver.

  • Unless specified otherwise, all numerical solutions will be transformed back into linear space from logspace before being returned.

  • Boundary reactions (a.k.a. reactions with only one metabolite involved) are excluded automatically. To work with reactions that cross compartment boundaries, MassMetabolite objects need to be defined for the metabolites in both compartments.

Parameters
  • model (MassModel) – The mass model to associated with the ConcSolver instance. The model is used to populate the solver with typical variables and constraints upon initialization.

  • excluded_metabolites (iterable or None) – An iterable of model MassMetabolite objects or their identifiers in populating the solver with metabolite concentration variables and reaction constraints. If None, no metabolites are excluded.

  • excluded_reactions (iterable or None) – An iterable of model MassReaction objects or their identifiers in populating the solver with reaction equilibrium constant variables and reaction constraints. If None, no reactions are excluded.

  • equilibrium_reactions (iterable or None) – An iterable of model MassReaction objects or their identifiers that are intended to be at equilibrium. Reactions with steady state flux values equal to 0. are typically ignored unless they are specified in the ConcSolver.equilibrium_reactions

  • constraint_buffer (float or None) –

    A float value to use as a constraint buffer for all constraints.

    Default is 0..

  • **kwargs

    exclude_infinite_Keqs :

    bool indicating whether to exclude reactions with equilibrium constant values of infinity from the concentration solver.

    Default is True.

    fixed_conc_bounds :

    An iterable containing metabolites whose concentrations are to be set as fixed variables, meaning that their lower and upper bounds are equal to the base value.

    fixed_Keq_bounds :

    An iterable containing reactions whose equilibrium constants are to be set as fixed variables, meaning that their lower and upper bounds are equal to the base value.

    decimal_precision :

    bool indicating whether to apply the decimal_precision attribute of the MassConfiguration to the bound values.

    Default is False.

    zero_value_log_substitute :

    float value to substitute for 0 when trying to take the logarithm of 0 to avoid a domain error.

    Default is 1e-10.

problem_type

The type of mathematical problem that the concentration solver has been setup to solve.

Type

str

excluded_metabolites

A list of metabolite identifiers for model metabolites to exclude in populating the solver with metabolite concentration variables and reaction constraints.

Type

list

excluded_reactions

A list of reaction identifiers for model reactions to exclude in populating the solver with reaction equilibrium constant variables and reaction constraints.

Type

list

equilibrium_reactions

A list of reaction identifiers for model reactions that are intended to be at equilibrium.

Type

list

constraint_buffer

A value to utilize when setting a constraint buffer.

Type

float

property model[source]

Return the model associated with the ConcSolver.

property solver[source]

Get or set the attached solver of the ConcSolver.

When using a HistoryManager context, this attribute can be set temporarily, reversed when the exiting the context.

Parameters

value (str) – The optimization solver for problems concerning metabolite concentrations. The solver choices are the ones provided by optlang and solvers installed in your environment. Valid solvers typically include: "glpk", "cplex", "gurobi"

Notes

  • Like the Model.solver attribute, the concentration solver instance is the associated solver object, which manages the interaction with the associated solver, e.g. glpk.

  • This property is useful for accessing the concentration optimization problem directly and for defining additional constraints.

property tolerance[source]

Get or set the tolerance for the solver of the ConcSolver.

When using a HistoryManager context, this attribute can be set temporarily, reversed when the exiting the context.

Parameters

value (float) – The tolerance of the concentration solver.

property objective[source]

Get or set the solver objective.

When using a HistoryManager context, this attribute can be set temporarily, reversed when the exiting the context.

Parameters

value (dict, str, int, MassMetabolite, Objective, or Basic) –

The following are allowable values to set as the objective.

  • dict where metabolites are keys, linear coefficients as values.

  • str identifier of a MassMetabolite or the metabolite object itself.

  • int metabolite index in MassModel.metabolites

  • An Objective or a sympy expression to be directly interpreted as objectives.

property objective_direction[source]

Get or set the objective direction.

When using a HistoryManager context, this attribute can be set temporarily, reversed when the exiting the context.

Parameters

value (str) – The objective direction. Can be either "max" for the maximum, or "min" for the minimum.

property problem[source]

Return the interface to the underlying mathematical problem.

Solutions to the ConcSolver are obtained by formulating a mathematical problem and solving it. The optlang package is used to accomplish that and with this property, the problem interface can be accessed directly.

Returns

The problem interface that defines methods for interacting with the problem and associated solver directly.

Return type

optlang.interface

property variables[source]

Return the mathematical variables in the ConcSolver.

In a ConcSolver, most variables are metabolites and reaction equilibrium constants. However, for specific use cases, it may also be useful to have other types of variables. This property defines all variables currently associated with the underlying problem of the ConcSolver.

Notes

  • All variables exist in logspace.

Returns

A container with all associated variables.

Return type

optlang.container.Container

property constraints[source]

Return the constraints in the ConcSolver.

In a ConcSolver, most constraints are thermodynamic constraints relating the reaction equilibrium constant to the reaction metabolite concentrations.However, for specific use cases, it may also be useful to have other types of constraints. This property defines all constraints currently associated with the underlying problem of the ConcSolver.

Notes

  • All constraints exist in logspace.

Returns

A container with all associated constraints.

Return type

optlang.container.Container

property included_metabolites[source]

Return a list of metabolite identifiers included in the solver.

These are the metabolites not in the ConcSolver.excluded_metabolites attribute.

property included_reactions[source]

Return a list of reaction identifiers included in the solver.

These are the reactions not in the ConcSolver.excluded_reactions attribute.

property zero_value_log_substitute[source]

Get or set the a value to substitute for 0 when taking the log of 0.

A value of 1e-10 means that instead of attempting log(0) which causes a ValueError, it will be instead calculated as log(1e-10).

Parameters

value (float) – A positive value to use instead of 0 when taking the logarithm.

setup_sampling_problem(metabolites=None, reactions=None, conc_percent_deviation=0.2, Keq_percent_deviation=0.2, **kwargs)[source]

Set up the solver’s mathematical problem for concentraiton sampling.

Notes

  • This involves changing solver variable bounds based on the percent deviation of the base value, removing the objective, and setting the problem_type to "sampling".

  • If a percent deviation value is large enough to create a negative lower bound, it is set as the zero_value_log_substitute value to ensure that returned values are not negative.

Parameters
  • metabolites (iterable or None) – An iterable of metabolites whose concentration variable bounds are to be changed. If None, all metabolites except those that are in the ConcSolver.excluded_metabolites list are used.

  • reactions (iterable or None) – An iterable of reactions whose equilibrium constant variable bounds are to be changed. If None, all reactions except those that are in the ConcSolver.excluded_reactions list are used.

  • conc_percent_deviation (float) –

    A non-negative number indicating the percent to deviate from the initial concentration to set as the lower and upper bounds for sampling.

    If a value of 0. is given, all given reaction equilibrium constants are set as fixed variables. Default is 0.2 for a 20% deviation from the base value.

  • Keq_percent_deviation (float) –

    A non-negative number indicating the percent to deviate from the base reaction equilibrium constant to set as the lower and upper bounds for sampling.

    If a value of 0. is given, all given reaction equilibrium constants are set as fixed variables. Default is 0.2 for a 20% deviation from the base value.

  • **kwargs

    fixed_conc_bounds :

    An iterable containing metabolites whose concentrations are to be set as fixed variables, meaning that their lower and upper bounds are equal to the base value.

    fixed_Keq_bounds :

    An iterable containing reactions whose equilibrium constants are to be set as fixed variables, meaning that their lower and upper bounds are equal to the base value.

    decimal_precision :

    bool indicating whether to apply the decimal_precision attribute of the MassConfiguration to the bound values.

    Default is False.

setup_feasible_qp_problem(metabolites=None, reactions=None, **kwargs)[source]

Set up the solver’s mathematical problem for feasible conc. QP.

Notes

  • This involves changing solver variable bounds to [0, inf], setting the objective as a QP problem, and setting the problem_type to "feasible_qp".

  • The ConcSolver.solver must have QP capabilities.

Parameters
  • metabolites (iterable or None) – An iterable of metabolites whose concentration variable bounds are to be changed. If None, all metabolites except those that are in the ConcSolver.excluded_metabolites list are used.

  • reactions (iterable or None) – An iterable of reactions whose equilibrium constant variable bounds are to be changed. If None, all reactions except those that are in the ConcSolver.excluded_reactions list are used.

  • **kwargs

    fixed_conc_bounds :

    An iterable containing metabolites whose concentrations are to be set as fixed variables, meaning that their lower and upper bounds are equal to the base value.

    fixed_Keq_bounds :

    An iterable containing reactions whose equilibrium constants are to be set as fixed variables, meaning that their lower and upper bounds are equal to the base value.

    decimal_precision :

    bool indicating whether to apply the decimal_precision attribute of the MassConfiguration to the bound values.

    Default is False.

Raises

TypeError – Raised when the current solver does not have QP capabilities

See also

choose_solver

Method to choose a solver with QP capabilities

choose_solver(solver=None, qp=False)[source]

Choose a solver given a solver name.

This will choose a solver compatible with the ConcSolver and required capabilities.

Also respects ConcSolver.solver where it can.

Parameters
  • solver (str) – The name of the solver to be used.

  • qp (boolean) – Whether the solver needs Quadratic Programming capabilities. Default is False.

Returns

solver – Returns a valid solver for the problem.

Return type

optlang.interface.Model

Raises

SolverNotFound – If no suitable solver could be found.

add_cons_vars(what, **kwargs)[source]

Add constraints and variables to the solver’s problem.

Useful for variables and constraints that cannot be expressed through metabolite concentrations and reaction equilibrium constants.

Additions are reversed upon exit if the solver itself is used as context.

Parameters
  • what (list, tuple) – Either a list or a tuple of variables or constraints to add to the solver. Must be of optlang.interface.Variable or optlang.interface.Constraint.

  • **kwargs (keyword arguments) – Passed to solver.add().

remove_cons_vars(what)[source]

Remove constraints and variables from the solver’s problem.

Remove variables and constraints that were added directly to the solver’s underlying mathematical problem. Removals are reversed upon exit if the model itself is used as context.

Parameters

what (list, tuple) – Either a list or a tuple of variables or constraints to remove from the solver. Must be of optlang.interface.Variable or optlang.interface.Constraint.

reset_constraints()[source]

Reset the constraints.

Ensures constraints are updated if solver’s problem changes in any way.

add_excluded_metabolites(metabolites, reset_problem=False)[source]

Add metabolites to the exclusion list for problem creation.

Note that this will not remove metabolites from the current problem. The problem must first be reset in order for changes to take effect.

Parameters
  • metabolites (iterable) – An iterable of MassMetabolite objects or their identifiers to be added to the excluded_metabolites.

  • reset_problem (bool) – Whether to reset the underlying mathematical problem of the solver to a generic one after adding additional metabolites to exclude. If False then it is incumbent upon the user to remove the newly excluded metabolites from the solver.

remove_excluded_metabolites(metabolites, reset_problem=False)[source]

Remove metabolites from the exclusion list for problem creation.

Note that this will not add metabolites to the current problem. The problem must first be reset in order for changes to take effect.

Parameters
  • metabolites (iterable) – An iterable of MassMetabolite objects or their identifiers to be removed from the excluded_metabolites.

  • reset_problem (bool) – Whether to reset the underlying mathematical problem of the solver to a generic one after removing additional metabolites to exclude. If False then it is incumbent upon the user to add the newly included metabolites to the solver.

add_excluded_reactions(reactions, reset_problem=False)[source]

Add reactions to the exclusion list for problem creation.

Note that this will not remove reaction equilibrium constants or constraints from the current problem. The problem must first be reset in order for changes to take effect.

Parameters
  • reactions (iterable) – An iterable of MassReaction objects or their identifiers to be added to the excluded_reactions.

  • reset_problem (bool) – Whether to reset the underlying mathematical problem of the solver to a generic one after adding additional reactions to exclude. If False then it is incumbent upon the user to remove the newly excluded reactions from the solver.

remove_excluded_reactions(reactions, reset_problem=False)[source]

Remove reactions from the exclusion list for problem creation.

Note that this will not add reaction equilibrium constants or constraints to the current problem. The problem must first be reset in order for changes to take effect.

Parameters
  • reactions (iterable) – An iterable of MassReaction objects or their identifiers to be removed from the excluded_reactions.

  • reset_problem (bool) – Whether to reset the underlying mathematical problem of the solver to a generic one after removing additional reactions to exclude. If False then it is incumbent upon the user to add the newly included reaction equilibrium constants and constraints to the solver.

add_equilibrium_reactions(reactions, reset_problem=False)[source]

Add additional reaction to the equilibrium reaction list.

The problem must first be reset in order for changes to take effect as a result of adding additional equilibrium reactions.

Parameters
  • reactions (iterable) – An iterable of MassReaction objects or their identifiers to be added to the equilibrium_reactions.

  • reset_problem (bool) – Whether to reset the underlying mathematical problem of the solver to a generic one after adding additional equilibrium reactions. If False then it is incumbent upon the user to make the changes necessary for the mathematical problem of the solver.

remove_equilibrium_reactions(reactions, reset_problem=False)[source]

Remove reactions from the equilibrium reaction list.

The problem must first be reset in order for changes to take effect as a result of removing equilibrium reactions.

Parameters
  • reactions (iterable) – An iterable of MassReaction objects or their identifiers to be removed from the equilibrium_reactions.

  • reset_problem (bool) – Whether to reset the underlying mathematical problem of the solver to a generic one after removing equilibrium reactions. If False then it is incumbent upon the user to make the changes necessary for the mathematical problem of the solver.

optimize(objective_sense=None, raise_error=False, **kwargs)[source]

Optimize the ConcSolver.

Notes

Only the most commonly used parameters are presented here. Additional parameters for solvers may be available and specified with the appropriate keyword argument.

Parameters
  • objective_sense (str or None) – Either "maximize" or "minimize" indicating whether variables should be maximized or minimized. In case of None, the previous direction is used.

  • raise_error (bool) – If True, raise an OptimizationError if solver status is not optimal.

  • **kwargs

    decimal_precision :

    bool indicating whether to apply the decimal_precision attribute of the MassConfiguration to the solution values.

    Default is False.

slim_optimize(error_value=float('nan'), message=None, **kwargs)[source]

Optimize model without creating a ConcSolution object.

Creating a full solution object implies fetching shadow prices and solution values for all variables and constraints in the solver.

This necessarily takes some time and in cases where only one or two values are of interest, it is recommended to instead use this function which does not create a solution object, returning only the value of the objective.

Note however that the slim_optimize() method uses efficient means to fetch values so if you need solution values or shadow prices for more than say 4 metabolites/reactions, then the total speed increase of slim_optimize() versus optimize() is expected to be small or even negative depending on other methods of fetching values after optimization.

Parameters
  • error_value (float or None) – The value to return if optimization failed due to e.g. infeasibility. If None, raise OptimizationError if the optimization fails.

  • message (string) – Error message to use if the optimization did not succeed.

  • **kwargs

    decimal_precision :

    bool indicating whether to apply the decimal_precision attribute of the MassConfiguration to the solution values.

    Default is False.

Returns

The objective value.

Return type

float

set_objective(value, additive=False)[source]

Set the model objective.

Parameters
  • value (optlang.interface.Objective, Basic, or dict) – If the objective is linear, the value can be a new optlang.interface.Objective object or a dict with linear coefficients where each key is a metabolite and the element the new coefficient (float).

  • additive (bool) – If True, add the terms to the current objective, otherwise start with an empty objective.

add_metabolite_var_to_problem(metabolite, lower_bound=None, upper_bound=None, **kwargs)[source]

Add a metabolite concentration variable to the problem.

The variable in linear space is represented as:

log(x_lb) <= log(x) <= log(x_ub)

where

  • x is the metabolite concentration variable.

  • x_lb is the lower bound for the concentration.

  • x_ub is the upper bound for the concentration.

Parameters
  • metabolite (MassMetabolite) – The metabolite whose concentration should be added as a variable to the solver.

  • lower_bound (float) – A non-negative number for the lower bound of the variable. If bound_type=deviation then value is treated as a percentage. Otherwise value is treated as the lower bound in linear space.

  • upper_bound (float) – A non-negative number for the upper bound of the variable. If bound_type=deviation then value is treated as a percentage. Otherwise value is treated as the lower bound in linear space.

  • **kwargs

    bound_type :

    Either "deviation" to indicate that bound values are percentages representing deviations of the base concentration value, or "absolute" to indicate that the bound values should be not be treated as percentages but as the bound values themselves (in linear space).

    Default is deviation.

    concentration :

    A non-negative number to treat as the base concentration value in setting percent deviation bounds. Ignored if bound_type=absolute

    Default is the current metabolite concentration accessed via MassMetabolite.initial_condition.

    decimal_precision :

    bool indicating whether to apply the decimal_precision attribute of the MassConfiguration to the bound values.

    Default is False.

add_reaction_Keq_var_to_problem(reaction, lower_bound=None, upper_bound=None, **kwargs)[source]

Add a reaction equilibrium constant variable to the problem.

The variable in linear space is represented as:

log(Keq_lb) <= log(Keq) <= log(Keq_ub)

where

  • Keq is the equilibrium constant variable for the reaction.

  • Keq_lb is the lower bound for the equilibrium constant.

  • Keq_ub is the upper bound for the equilibrium constant.

Parameters
  • reaction (MassReaction) – The reaction whose equilibrium constant should be added as a variable to the solver.

  • lower_bound (float) – A non-negative number for the lower bound of the variable. If bound_type=deviation then value is treated as a percentage. Otherwise value is treated as the lower bound in linear space.

  • upper_bound (float) – A non-negative number for the upper bound of the variable. If bound_type=deviation then value is treated as a percentage. Otherwise value is treated as the lower bound in linear space.

  • **kwargs

    bound_type :

    Either "deviation" to indicate that bound values are percentages representing deviations of the base equilibrium constant value, or "absolute" to indicate that the bound values should be not be treated as percentages but as the bound values themselves (in linear space).

    Default is deviation.

    Keq :

    A non-negative number to treat as the base equilibrium constant value in setting percent deviation bounds. Ignored if bound_type=absolute

    Default is the current reaction equilibrium constant accessed via MassReaction.equilibrium_constant.

    steady_state_flux :

    The steady state flux value of the reaction. If set as 0., the creation of the equilibrium constant variable will depend on whether the reaction is defined as an equilibrium reaction.

    Default is the current reaction steady state flux accessed via MassReaction.steady_state_flux.

    decimal_precision :

    bool indicating whether to apply the decimal_precision attribute of the MassConfiguration to the bound values.

    Default is False.

add_concentration_Keq_cons_to_problem(reaction, epsilon=None, **kwargs)[source]

Add constraint using the reaction metabolite stoichiometry and Keq.

The constraint in linear space is represented as:

S^T * log(x) <= log(Keq) - epsilon if v > 0
S^T * log(x) >= log(Keq) + epsilon if v < 0

where

  • S^T is the transposed stoichiometry for the reaction.

  • x is the vector of concentration variables.

  • Keq is the equilibrium constant variable for the reaction.

  • v is the steady state flux value for the reaction.

  • epsilon is a buffer for the constraint .

Parameters
  • reaction (MassReaction) – The reaction whose metabolite stoichiometry and equilibrium constant is used to create the constraint to be added.

  • epsilon (float) –

    The buffer for the constraint.

    Default is None to use ConcSolver.constraint_buffer.

  • **kwargs

    bound_type :

    Either "deviation" to indicate that bound values are percentages representing deviations of the base equilibrium constant value, or "absolute" to indicate that the bound values should be not be treated as percentages but as the bound values themselves (in linear space). Only used if the variables necessary for the constraint do not already exist.

    Default is deviation.

    steady_state_flux :

    The steady state flux value of the reaction. Determines whether the contraint is set up as less than or as greater than. If set as 0., the creation of the reaction constraint will depend on whether the reaction is defined as an equilibrium reaction.

    Default is the current reaction steady state flux accessed via MassReaction.steady_state_flux.

    decimal_precision :

    bool indicating whether to apply the decimal_precision attribute of the MassConfiguration to the bound values.

    Default is False.

update_model_with_solution(concentration_solution, **kwargs)[source]

Update ConcSolver.model using a ConcSolution.

Parameters
  • concentration_solution (ConcSolution) – The ConcSolution containing the solution values to use in updating the model.

  • **kwargs

    concentrations :

    bool indicating whether to update the metabolite concentrations of the model (the MassMetabolite.initial_condition values).

    Default is True.

    Keqs :

    bool indicating whether to update the reaction equilibrium constants of the model (the MassReaction.equilibrium_constant values).

    Default is True.

    inplace :

    bool indicating whether to modify the current ConcSolver.model or to copy the model, then modify and set the model copy as the new ConcSolver.model. If False, the association with the old model is removed and an association with the new model is created.

    Default is True.

_create_variable(mass_obj, lower_bound, upper_bound, **kwargs)[source]

Create an optlang variable for the solver.

Warning

This method is intended for internal use only.

_initialize_solver(reset_problem=False, **kwargs)[source]

Initialize the solver as a generic problem involving concentraitons.

Warning

This method is intended for internal use only.

_get_included_metabolites(metabolites=None)[source]

Return a list of MassMetabolite objects for included metabolites.

Warning

This method is intended for internal use only.

_get_included_reactions(reactions=None)[source]

Return a list of MassReaction objects for included reactions.

Warning

This method is intended for internal use only.

_check_for_missing_values(model, concentrations=True, equilibrium_constants=True, steady_state_fluxes=True)[source]

Determine missing values that prevent setup of a problem.

Warning

This method is intended for internal use only.

__dir__()[source]

Override default dir() implementation to list only public items.

Warning

This method is intended for internal use only.

__repr__()[source]

Override default repr.

Warning

This method is intended for internal use only.

__enter__()[source]

Record all future changes, undoing them when __exit__ is called.

Warning

This method is intended for internal use only.

__exit__(type, value, traceback)[source]

Pop the top context manager and trigger the undo functions.

Warning

This method is intended for internal use only.

mass.thermo.conc_solver.concentration_constraint_matricies(concentration_solver, array_type='dense', zero_tol=1e-06)[source]

Create a matrix representation of the problem.

This is used for alternative solution approaches that do not use optlang. The function will construct the equality matrix, inequality matrix and bounds for the complete problem.

Parameters
  • concentration_solver (ConcSolver) – The ConcSolver containing the mathematical problem.

  • array_type (str) – A string identifiying the desired format for the returned matrix. Valid matrix types include 'dense', 'dok', 'lil', 'DataFrame', and 'symbolic' Default is the current dense. See the matrix module documentation for more information on the array_type.

  • zero_tol (float) – The zero tolerance used to judge whether two bounds are the same.

Returns

A named tuple consisting of 6 matrices and 2 vectors:

  • "equalities" is a matrix S such that S*vars = b. It includes a row for each equality constraint and a column for each variable.

  • "b" the right side of the equality equation such that S*vars = b.

  • "inequalities" is a matrix M such that lb <= M*vars <= ub. It contains a row for each inequality and as many columns as variables.

  • "bounds" is a compound matrix [lb ub] containing the lower and upper bounds for the inequality constraints in M.

  • "variable_fixed" is a boolean vector indicating whether the variable at that index is fixed (lower bound == upper_bound) and is thus bounded by an equality constraint.

  • "variable_bounds" is a compound matrix [lb ub] containing the lower and upper bounds for all variables.

Return type

collections.namedtuple