The model passed to LINGO to solve this problem is the familiar staffing model we've used before with some modifications, and appears below with important changes in bold:

MODEL:

SETS:

   DAYS / MON TUE WED THU FRI SAT SUN/:

    NEEDS, START, ONDUTY;

ENDSETS

 

[OBJECTIVE] MIN = @SUM( DAYS( I): START( I));

 

@FOR( DAYS( TODAY):

 

! Calculate number on duty;

   ONDUTY( TODAY) =

    @SUM( DAYS( D)| D #LE# 5:

     START( @WRAP( TODAY - D + 1,

      @SIZE( DAYS))));

 

! Enforce staffing requirement;

   ONDUTY( TODAY) >= NEEDS( TODAY);

 

   @GIN( START);

);

 

DATA:

   NEEDS = @POINTER( 1);

   @POINTER( 2) = START;

   @POINTER( 3) = ONDUTY;

   @POINTER( 4) = OBJECTIVE;

   @POINTER( 5) = @STATUS();

ENDDATA

END

Model: STAFFPTR

Since the LINGO script processor will read the model, it must begin with the MODEL: command and end with the END command. The script processor treats all text between the MODEL: and END keywords as model text, as opposed to script commands.

We have added the ONDUTY attribute to compute the number of employees on duty each day. We compute these figures for the purpose of passing them back to the calling application, which, in turn, posts them in the dialog box in the On Duty column.

We have named the objective row OBJECTIVE for the purpose of returning the objective's value to the calling application, so it may place the value in the Total cell.