Overview | Group | Tree | Graph | Index | Concepts |
The class IlcTransitionCostObjectI
defines a set of
functions that calculate the transition, setup, and teardown costs between
resource constraints. Its handle class can be passed as an argument to the
function IlcUnaryResource::addNextTransitionCost
or
IlcUnaryResource::addPrevTransitionCost
to declare that it is a
cost to factor into a sequence constraint added to the resource.
The transition cost is the cost to have the activity of one resource constraint as the successor to the activity of another. The setup cost of a resource constraint is the cost for its activity to be sequenced first. The teardown cost of a resource constraint is the cost for its activity to be sequenced last.
The transition cost can be variable or constant. By constant we mean that it only depends upon the precedence relationship between two activities. By variable we mean that the evaluation of the transition cost depends upon current knowledge about the other variables and constraints involved. If it is variable, the transition cost object must define its minimal and maximal value given the current knowledge about the sequence.
To define an IlcTransitionCostObjectI
subclass adapted to
your needs, you have to encode the virtual functions declared in the
IlcTransitionCostObjectI
class. For a constant transition cost,
you have only to redefine the virtual function IlcTransitionCostObjectI::getTransitionCost
and, if needed, IlcTransitionCostObjectI::getSetupCost
and IlcTransitionCostObjectI::getTeardownCost
. For a variable transition cost, you have
only to redefine the virtual functions IlcTransitionCostObjectI::getTransitionCostMax
, IlcTransitionCostObjectI::getTransitionCostMin
and, if needed, IlcTransitionCostObjectI::getSetupCostMax
, IlcTransitionCostObjectI::getSetupCostMin
, IlcTransitionCostObjectI::getTeardownCostMax
, and IlcTransitionCostObjectI::getTeardownCostMin
.
See the Example which follows.
Example
Suppose you have a unary resource that represents a machine. Between the execution of two tasks on the machine, some workers are required to perform a maintenance operation to reset the machine. You know that this maintenance operation has a given duration (the transition time between two jobs), starts after the end of the first task, and ends before the start of the next task.
To express this last constraint you need to be able to access the start variable of the next task. As you don't know in advance which task will be the next of an activity, this may pose a problem. However, the variable transition cost facility is well suited to express this constraint.
class StartTransitionCostI : public IlcTransitionCostObjectI { public: StartTransitionCostI(); ~StartTransitionCostI(); virtual IlcInt getTransitionCostMax (const IlcResourceConstraint srct1, const IlcResourceConstraint srct2) const; virtual IlcInt getTransitionCostMin (const IlcResourceConstraint srct1, const IlcResourceConstraint srct2) const; virtual IlcInt getSetupCostMin (const IlcResourceConstraint srct1) const; virtual IlcInt getSetupCostMax (const IlcResourceConstraint srct1) const; virtual IlcInt getTeardownCostMin (const IlcResourceConstraint srct1) const; virtual IlcInt getTeardownCostMax (const IlcResourceConstraint srct1) const; }; StartTransitionCostI::StartTransitionCostI() // the transition cost is variable :IlcTransitionCostObjectI(IlcTrue) {} StartTransitionCostI::~StartTransitionCostI() {} IlcInt StartTransitionCostI::getTransitionCostMax (const IlcResourceConstraint, const IlcResourceConstraint srct2) const { return srct2.getActivity().getStartMax(); } IlcInt StartTransitionCostI::getTransitionCostMin (const IlcResourceConstraint, const IlcResourceConstraint srct2) const { return srct2.getActivity().getStartMin(); } IlcInt StartTransitionCostI::getSetupCostMin (const IlcResourceConstraint srct1) const { return srct1.getActivity().getStartMin(); } IlcInt StartTransitionCostI::getSetupCostMax (const IlcResourceConstraint srct1) const { return srct1.getActivity().getStartMax(); } IlcInt StartTransitionCostI::getTeardownCostMin (const IlcResourceConstraint srct1) const { return srct1.getActivity().getSchedule().getTimeMax(); } IlcInt StartTransitionCostI::getTeardownCostMax (const IlcResourceConstraint srct1) const { return srct1.getActivity().getSchedule().getTimeMax(); } // Must be used during search (e.g., inside a goal) IloSolver solver = getSolver(); IlcScheduler schedule(solver, 0, 1000); IlcUnaryResource machine(schedule); IlcDiscreteResource workers(schedule, 10); // Must be used during search (e.g., inside a goal) IlcActivity task1(schedule, 100); IlcResourceConstraint rct1 = task1.requires(machine); solver.add(rct1); // Must be used during search (e.g., inside a goal) machine.close(); solver.add(machine.makeSequenceConstraint()); IlcTransitionCostObject startObj = new (solver.getHeap()) StartTransitionCostI(); machine.addNextTransitionCost(startObj); // Must be used during search (e.g., inside a goal) IlcActivity maintenance1(schedule, 20); solver.add(maintenance1.getStartVariable() >= task1.getEndVariable()); solver.add(maintenance1.getEndVariable() <= machine.getNextTransitionCostVar(startObj, rct1)); solver.add(maintenance1.requires(workers, 3));
For more information, see Sequence Constraint.
See Also:
IlcResourceConstraint, IlcTransitionCostObject
Constructor and Destructor Summary | |
---|---|
public | IlcTransitionCostObjectI(IlcBool isVariable=IlcFalse) |
Method Summary | |
---|---|
public virtual IlcInt | getSetupCost(const IlcResourceConstraint srct1) const |
public virtual IlcInt | getSetupCostMax(const IlcResourceConstraint srct1) const |
public virtual IlcInt | getSetupCostMin(const IlcResourceConstraint srct1) const |
public virtual IlcInt | getTeardownCost(const IlcResourceConstraint srct1) const |
public virtual IlcInt | getTeardownCostMax(const IlcResourceConstraint srct1) const |
public virtual IlcInt | getTeardownCostMin(const IlcResourceConstraint srct1) const |
public virtual IlcInt | getTransitionCost(const IlcResourceConstraint srct1, const IlcResourceConstraint srct2) const |
public virtual IlcInt | getTransitionCostMax(const IlcResourceConstraint srct1, const IlcResourceConstraint srct2) const |
public virtual IlcInt | getTransitionCostMin(const IlcResourceConstraint srct1, const IlcResourceConstraint srct2) const |
public IlcBool | isVariable() const |
Constructor and Destructor Detail |
---|
This constructor creates an instance of
IlcTransitionCostObjectI
. The Boolean argument
isVariable
specifies whether the transition cost is or is not
variable.
Method Detail |
---|
This virtual member function returns the constant setup cost of the
activity of the resource constraint srct1
. The setup cost is
the cost for this activity to be first in the sequence. By default, it
returns 0.
This virtual member function returns the maximum variable setup cost of
the activity of the resource constraint srct1
. The setup cost
is the cost for this activity to be first in the sequence. By default, it
returns 0.
This virtual member function returns the minimum variable setup cost of
the activity of the resource constraint srct1
. The setup cost
is the cost for this activity to be first in the sequence. By default, it
returns 0.
This virtual member function returns the constant teardown cost of the
activity of the resource constraint srct1
. The teardown cost is
the cost for this activity to be last in the sequence. By default, it
returns 0.
This virtual member function returns the maximum variable teardown cost
of the activity of the resource constraint srct1
. The teardown
cost is the cost for this activity to be last in the sequence. By default,
it returns 0.
This virtual member function returns the minimum variable teardown cost
of the activity of the resource constraint srct1
. The teardown
cost is the cost for this activity to be last in the sequence. By default,
it returns 0.
This virtual member function returns the constant transition cost if the
activity of resource constraint srct1
immediately precedes the
activity of resource constraint srct2
in the sequence. By
default, it raises an error.
This virtual member function returns the maximum variable transition cost
if the activity of the resource constraint srct1
immediately
precedes the activity of the resource constraint srct2
in the
sequence. By default, it raises an error if the invoking instance is
variable and returns the constant transition cost if the invoking instance
is constant.
This virtual member function returns the minimum variable transition cost
if the activity of the resource constraint srct1
immediately
precedes the activity of the resource constraint srct2
in the
sequence. By default, it raises an error if the invoking instance is
variable and returns the constant transition cost if the invoking instance
is constant.
This member function returns IlcTrue
if the invoking
instance of IlcTransitionCostObjectI
is variable. Otherwise, it
returns IlcFalse
.