picos.reforms.reformulation¶
Backend for problem reformulation classes.
Classes
- class picos.reforms.reformulation.Reformulation(theObject)[source]¶
Bases:
abc.ABC
Base class for problem reformulations.
Abstract base class for a reformulation from one (possibly already reformulated) problem form to another.
- __init__(theObject)[source]¶
Initialize
Reformulation
instances.- Parameters
theObject (Problem or Reformulation) – The input to work on; either an optimization problem or the (future) output of another reformulation.
- abstract backward(solution)[source]¶
Translate back a solution from reformulated to original problem.
Transforms a single
Solution
tooutput
to a solution ofinput
.The method is allowed to modify the solution; it is not necessary to work on a copy. In particular,
attach_to
can be used ifforward
has created a deep copy of the problem.
- execute()[source]¶
Reformulate the problem and obtain a solution from the result.
For this to work there needs to be a solver instance at the end of the reformulation pipeline, which would implement its own version of this method that actually solves the problem and produces the first solution.
- abstract forward()[source]¶
Perform the initial problem reformulation.
Creates a modified copy or clone of the problem in
input
and stores it asoutput
.See
copy
andclone
for the differences between a copy and a clone.Implementations are supposed to do the necessary bookkeeping so that
backward
can transform a solution to the new problem back to a solution of the original problem.
- abstract classmethod predict(footprint)[source]¶
Predict the reformulation’s effect on a problem footprint.
Given a problem footprint, returns another problem footprint that a problem with the former one would be reformulated to.
This is used to predict the effects of a reformulation when planning a solution strategy without the cost of actually transforming a problem.
- reset()[source]¶
Reset the pipeline from this reformulation onward.
This is done whenever a reformulation does not implement
update
so that succeeding reformulations do not attempt to update a problem which was completely rewritten as this may be inefficient.
- abstract classmethod supports(footprint)[source]¶
Whether the reformulation affects problems with the given footprint.
The reformulation must support every problem with such a footprint and the resulting problem should have a changed footprint.
- abstract update()[source]¶
Update a previous problem reformulation.
Updates
output
and related bookkeeping information with respect to changes ininput
.- Raises
NotImplementedError – If performing an update is not feasible for the reformulation.
- property input¶
The input problem.
- output¶
The output problem.
- successor¶
The next reformulation in the pipeline.
- property verbosity¶
Verbosity level of the reformulation; same as for input problem.