We define a class, Activity
, with two member functions, setCritical
and isCritical
, for marking critical activities and two member functions, setSubProblem
and getSubProblem
, for marking to which subproblem the activity belongs.
class Activity {
private:
IloActivity _act;
IloBool _critical;
IloInt _subProblem;
public:
Activity(IloEnv env,
IloInt number,
IloInt processingTime);
~Activity();
IloActivity getActivity() const {
return _act;
}
void setCritical(IloBool critical) {
_critical = critical;
}
IloBool isCritical() const {
return _critical;
}
void setSubProblem(IloInt subProblem) {
_subProblem = subProblem;
}
IloInt getSubProblem() const {
return _subProblem;
}
};
The rest of the problem definition is quite similar to the one described in the previous chapter except that each activity of the schedule is associated with an object Activity
(by calling the constructor of the class Activity
).
void
DefineProblem(IloModel model,
IloInt numberOfActivities,
IloInt* processingTimes,
IloInt* demands,
IloInt capacity,
IloInt* precedences,
IloActivityArray& activities,
IloNumVar& makespan)
{
/* ... */
/* CREATE THE ACTIVITIES. */
activities = IloActivityArray(env,numberOfActivities);
for (i = 0; i < numberOfActivities; i++) {
Activity* act = new (env)
Activity(env, i + 1, processingTimes[i]);
activities[i] = act->getActivity();
model.add(activities[i].requires(resource, demands[i]));
}