FRAMES NO FRAMES

Class IlcIntervalList

Definition file: ilsched/breaks.h
Include file: <ilsched/ilsched.h>

An instance of the class IlcIntervalList represents a list of non-overlapping intervals. Each interval [timeMin, timeMax) from the list is associated with a numerical type.

Such time intervals can be used, for instance, to represent breaks or shifts. As each interval can be associated with an integer type, some specific behaviors can be defined on activities (ignore shift or break interval, break interval possibly overlapped, and so forth).

Break and shift intervals can be attached to a calendar and then associated with resources and resource constraints (see IlcCalendar).

Printing or Displaying Lists of Intervals

The printed representation of an instance of the class IlcIntervalList consists of its name, followed by the first chronological interval and the last interval. For example:

<[20->40). . .[70->80)> represents a list of intervals whose first interval occurs in the time interval [20 40) and whose last interval occurs in the time interval [70 80).

If the Solver trace is active and the resource is not named, the string "IlcIntervalList" is followed by the address of the implementation object. The address will be enclosed in parentheses.

For more information, see Calendars.

See Also:

Constructor Summary
public IlcIntervalList()
public IlcIntervalList(IlcIntervalListI * impl)
public IlcIntervalList(const IlcSchedule schedule)
Method Summary
public voidaddInterval(IlcInt start, IlcInt end, IlcInt type=OL)
public voidaddIntervalOnDuration(IlcInt start, IlcInt duration, IlcInt type=OL)
public voidaddPeriodicInterval(IlcInt start, IlcInt duration, IlcInt period)
public voidaddPeriodicInterval(IlcInt start, IlcInt duration, IlcInt period, IlcInt end, IlcInt type=0L)
public voidclose()
public IlcIntervalListI *getImpl() const
public const char *getName() const
public IlcAnygetObject() const
public IloSolvergetSolver() const
public IloSolverI *getSolverI() const
public IlcBoolisClosed() const
public IlcBoolisEmpty() const
public voidopen()
public voidoperator=(const IlcIntervalList & h)
public voidremoveInterval(IlcInt start, IlcInt end)
public voidremoveIntervalOnDuration(IlcInt start, IlcInt duration)
public voidremovePeriodicInterval(IlcInt start, IlcInt duration, IlcInt period, IlcInt end)
public voidremovePeriodicInterval(IlcInt start, IlcInt duration, IlcInt period)
public voidsetName(const char * name) const
public voidsetObject(IlcAny object) const
Constructor Detail

IlcIntervalList

public IlcIntervalList()
This constructor creates an empty handle. You must initialize it before you use it.

IlcIntervalList

public IlcIntervalList(IlcIntervalListI * impl)
This constructor creates a handle object from a pointer to an implementation object.

IlcIntervalList

public IlcIntervalList(const IlcSchedule schedule)

This constructor creates a new instance of IlcIntervalList and adds it to the set of interval lists managed by the given schedule. That newly constructed list of intervals is initially empty.


Method Detail

addInterval

public void addInterval(IlcInt start, IlcInt end, IlcInt type=OL)

This member function adds an interval of type type to the invoking list of intervals. The start time and end time of that newly added interval are set to start and end. By default, the type of the interval is 0.

An interval can be added to the interval list as long as it is not closed. The effect of this function is reversible.

Any attempt to add a new interval that overlaps with an already existing interval of a different type raises an error.


addIntervalOnDuration

public void addIntervalOnDuration(IlcInt start, IlcInt duration, IlcInt type=OL)

This member function adds an interval of type type to the invoking list of intervals. The start time of the newly added interval is start; its end time is start+duration. By default, the type of the interval is 0.

An interval can be added to the interval list as long as it is not closed. The effect of this function is reversible.

Any attempt to add a new interval that overlaps with an already existing interval of a different type raises an error.


addPeriodicInterval

public void addPeriodicInterval(IlcInt start, IlcInt duration, IlcInt period)

This member function adds a set of intervals of type 0 to the invoking list of intervals. For every i >= 0 such that start + i * period < horizon, an interval [start + i * period, start + duration + i * period) is added. horizon is the time horizon of the schedule that was given as an argument to the constructor of the invoking list of intervals. A periodic interval can be added to the interval list as long as it is not closed. The effect of this function is reversible.

Any attempt to add a new periodic interval that overlaps with an already existing interval of a different type raises an error.


addPeriodicInterval

public void addPeriodicInterval(IlcInt start, IlcInt duration, IlcInt period, IlcInt end, IlcInt type=0L)

This member function adds a set of intervals to the invoking list of intervals. For every i >= 0 such that start + i * period < end, an interval [start + i * period, start + duration + i * period) is added. By default, the type of the interval is 0.

A periodic interval can be added to the interval list as long as it is not closed. The effect of these functions is reversible.

Any attempt to add a new interval that overlaps with an already existing interval of a different type raises an error.


close

public void close()

This member function closes the interval list, which means that intervals can no longer be added or removed. The Scheduler Engine uses this knowledge to perform extra propagation. Closing an already closed interval list has no effect. This function is reversible.

Example

The following piece of code illustrates the extra propagation when a break list is closed.

   //Must be during search (e.g., inside a goal)

   IloSolver solver = getSolver();
   IlcScheduler schedule(solver,0,100);
   IlcUnaryResource res(schedule);
   IlcCalendar cal(schedule);
   IlcIntervalList bl(schedule);
   cal.setBreakList(bl);
   res.setCalendar(cal);
   IlcActivity act(schedule, 20, IlcTrue);
   solver.add(act.requires(res));
   solver.add(act.startsAt(10));
   solver.out() << act << endl;
   // [10 -- (20) 20..90 --> 30..100]
   bl.addInterval(20,50);
   solver.out() << act << endl;
   // [10 -- (20) 50..90 --> 60..100]
   bl.close();
   solver.out() << act << endl;
   // [10 -- (20) 50 --> 60]
 

getImpl

public IlcIntervalListI * getImpl() const
This constructor creates an object by copying another one. This constructor creates an object by copying another one. This member function returns a pointer to the implementation object of the invoking handle.

getName

public const char * getName() const
This member function returns the name of the invoking object.

getObject

public IlcAny getObject() const
This member function returns a pointer to the external object associated with the invoking object, if there is such an association. It returns 0 (zero) otherwise.

getSolver

public IloSolver getSolver() const

This member function returns an instance of IloSolver associated with the invoking object.


getSolverI

public IloSolverI * getSolverI() const

This member function returns a pointer to the implementation object of the solver where the invoking object was extracted.


isClosed

public IlcBool isClosed() const

This member function returns IlcTrue if the invoking interval list is closed. Otherwise, it returns IlcFalse.


isEmpty

public IlcBool isEmpty() const

This member function returns IlcTrue if the invoking interval list is empty. Otherwise, it returns IlcFalse.


open

public void open()

This member function opens an interval list so that it is possible to add or remove intervals on it. Opening an already opened interval list has no effect.

This member function is available only outside the search. Trying to open an interval list in search raises an error.


operator=

public void operator=(const IlcIntervalList & h)
This operator assigns an address to the handle pointer of the invoking object. That address is the location of the implementation object of the provided argument.

removeInterval

public void removeInterval(IlcInt start, IlcInt end)

This member function removes all intervals between start and end. If start is placed inside an interval [start1, end1), that is, start1 < start < end1, this results in an interval [start1, start). If end is placed inside an interval [start2, end2) this results in an interval [end, end2). The interval list must be open. Trying to remove an interval during the search or from a closed interval list raises an error.

This member function is available only outside the search.


removeIntervalOnDuration

public void removeIntervalOnDuration(IlcInt start, IlcInt duration)

This member function removes all intervals between start and start+duration. The interval list must be open. Trying to remove an interval during the search or from a closed interval list raises an error.

This member function is available only outside the search.


removePeriodicInterval

public void removePeriodicInterval(IlcInt start, IlcInt duration, IlcInt period, IlcInt end)

These member functions remove intervals from the invoking interval list. More precisely, for every i >= 0 such that start + i * period < end, these functions remove all intervals between start + i * period and start + duration + i * period. The invoking interval list must be open. Trying to remove a periodic interval during the search or from a closed interval list raises an error.

This member function is available only outside the search.


removePeriodicInterval

public void removePeriodicInterval(IlcInt start, IlcInt duration, IlcInt period)

These member functions remove intervals from the invoking interval list. More precisely, for every i >= 0 such that start + i * period < horizon, these functions remove all intervals between start + i * period and start + duration + i * period. horizon is the time horizon of the schedule that was given as an argument to the constructor of the invoking list. The invoking interval list must be open. Trying to remove a periodic interval during the search or from a closed interval list raises an error.

This member function is available only outside the search.


setName

public void setName(const char * name) const
This member function sets the name of the invoking object to a copy of name. This assignment is a reversible action.

setObject

public void setObject(IlcAny object) const
This member function establishes a link between the invoking object and an external object of which the invoking object might be a data member.