3.1.1.7.1.3. etfl.optim.utils

Optimisation utilities

3.1.1.7.1.3.1. Module Contents

3.1.1.7.1.3.1.1. Classes

SubclassIndexer

3.1.1.7.1.3.1.2. Functions

make_subclasses_dict(cls)

Return a dictionary of the subclasses inheriting from the argument class.

fix_integers(model)

Fixes all integer and binary variables of a model, to make it sample-able

_gurobi_fix_integers(model)

If the solver of the model whose integers to fix has Gurobi as a solver,

_generic_fix_integers(model)

Fix the integers of a model to its solution, and removes the variables.

rebuild_variable(classname, model, this_id, lb, ub, scaling_factor, queue=True)

Rebuilds a variable from a classname and link it to the model

rebuild_constraint(classname, model, this_id, new_expr, lb, ub, queue=True)

Rebuilds a constraint from a classname and link it to the model

is_gurobi(model)

Check if the model uses Gurobi as a solver

fix_growth(model, solution=None)

Set the growth integers to their fixed values from a solution. If no

check_solution(model, solution)

Helper function. if solution is None, attempts to get it from the model.

release_growth(model)

After growth has been fixed by etfl.optim.utils.fix_growth(),

apply_warm_start(model, solution)

Gives a warm start to the model.

release_warm_start(model)

Releases the warm start provided by

get_active_growth_bounds(model, growth_rate=None)

Returns the growth bound closest to the growth flux calculated at the

safe_optim(model)

Catches any exception that can happen during solving, and logs it.

get_binding_constraints(model, epsilon)

3.1.1.7.1.3.1.3. Attributes

INTEGER_VARIABLE_TYPES

DefaultSol

etfl.make_subclasses_dict(cls)

Return a dictionary of the subclasses inheriting from the argument class. Keys are String names of the classes, values the actual classes.

Parameters

cls

Returns

class etfl.SubclassIndexer
__getitem__(self, classtype)
purge(self)
refresh(self)
etfl.INTEGER_VARIABLE_TYPES = ['binary', 'integer']
etfl.fix_integers(model)

Fixes all integer and binary variables of a model, to make it sample-able :param model: :return:

etfl._gurobi_fix_integers(model)

If the solver of the model whose integers to fix has Gurobi as a solver, use the built-in method

Parameters

model – A model with a Gurobi backend

Returns

etfl._generic_fix_integers(model)

Fix the integers of a model to its solution, and removes the variables.

Parameters

model

Returns

etfl.rebuild_variable(classname, model, this_id, lb, ub, scaling_factor, queue=True)

Rebuilds a variable from a classname and link it to the model

Parameters
  • classname

  • model

  • this_id

  • lb

  • ub

  • queue

Returns

etfl.rebuild_constraint(classname, model, this_id, new_expr, lb, ub, queue=True)

Rebuilds a constraint from a classname and link it to the model

Parameters
  • classname

  • model

  • this_id

  • new_expr

  • lb

  • ub

  • queue

Returns

etfl.DefaultSol
etfl.is_gurobi(model)

Check if the model uses Gurobi as a solver

Parameters

model

Returns

etfl.fix_growth(model, solution=None)

Set the growth integers to their fixed values from a solution. If no solution is provided, the model’s latest solution is used. The growth can be released using the function etfl.optim.utils.release_growth()

Parameters
  • model

  • solution

Returns

etfl.check_solution(model, solution)

Helper function. if solution is None, attempts to get it from the model.

Parameters
  • model

  • solution

Returns

etfl.release_growth(model)

After growth has been fixed by etfl.optim.utils.fix_growth(), it can be released using this function.

Parameters

model

Returns

etfl.apply_warm_start(model, solution)

Gives a warm start to the model. Release it with etfl.optim.utils.release_warm_start().

Parameters
  • model

  • solution

Returns

etfl.release_warm_start(model)

Releases the warm start provided by etfl.optim.utils.apply_warm_start().

Parameters

model

Returns

etfl.get_active_growth_bounds(model, growth_rate=None)

Returns the growth bound closest to the growth flux calculated at the last solution.

Parameters

model

Returns

etfl.safe_optim(model)

Catches any exception that can happen during solving, and logs it. Useful if you solve many problems in a sequence and some of then are infeasible. Be careful : This wil catch literally any Exception.

Parameters

model

Returns

etfl.get_binding_constraints(model, epsilon)