pyepo.dsl.compiled

Generic compiled-problem base for the PyEPO DSL.

compiledBase is mixed with a backend base (optXxxModel) to form a concrete compiled problem, e.g. compiledGrbProblem(compiledBase, optGrbModel). It carries the backend-agnostic objective handling — scattering a predicted cost onto its variable positions and solving — while the concrete subclass builds the solver model and provides the read / write hooks.

Classes

compiledBase

Backend-agnostic compiled DSL problem. Mixed with an optXxxModel.

Module Contents

class pyepo.dsl.compiled.compiledBase(problem, params=None)

Bases: pyepo.model.opt.optModel

Backend-agnostic compiled DSL problem. Mixed with an optXxxModel.

problem
params
get_config() dict

Return the constructor configuration for this model.

property num_cost: int

number of costs to be predicted

property c_pred_index

Variable positions the predicted cost lands on, or None when every variable is predicted (the default).

setObj(c)

Set the objective from a predicted cost of length num_cost, scattered onto the known fixed costs.

solve()

Solve and return the full decision-vector solution (length num_vars) with its objective value.

addConstr(coefs, rhs)

A method to add a new constraint. Subclasses should override.

Parameters:
  • coefs – coefficients of the new constraint

  • rhs – right-hand side of new constraint

Returns:

new model with the added constraint

Return type:

optModel

relax()

A method to relax the MIP model. Subclasses should override.