IBM ILOG Scheduler User's Manual > Advanced Concepts > Scheduling with Unary Resources: the Job-Shop Problem > Defining the Problem, Designing a Model > Schedule

No time origin nor horizon is specified in the problem. Since the problem statement refers to no absolute date, the time origin can arbitrarily be set to 0. The time horizon can be set to the sum of the durations of the activities, since performing all activities one after the other (in an order compatible with the order imposed by each job) results in a solution to the problem. Similarly, the constrained makespan variable can be created with 0 as its minimal value and the sum of the durations of the activities as its maximal value.

IloModel
DefineModel(const IloEnv& env,
            IloInt numberOfJobs,
            IloInt numberOfResources,        
            IloInt* resourceNumbers,
            IloInt* durations,
            IloNumVar& makespan,
            IloAnyArray& jobs)
{
  IloModel model(env);
 
  /* CREATE THE MAKESPAN VARIABLE. */
  IloInt numberOfActivities = numberOfJobs * numberOfResources;
  IloInt horizon = 0;
  IloInt k;
  for (k = 0; k < numberOfActivities; k++)
    horizon += durations[k];
 
  makespan = IloNumVar(env, 0, horizon, ILOINT);
 
  /* ... */ 
  /* RETURN THE MODEL. */
  delete [] resources;
  return model;
}