Writing Custom Sequence Rules

To rank request queues, the logic of each sequencing rule is written into a load-ranking function. You can write and install tailored load ranking functions to sequence queues by rules that are specific to your manufacturing operation.
Note:  See Writing a Custom Scheduler Rule for a summary of the steps required to create custom rules. For more details about the functions described in this topic, see the Scheduling Customization Guide, available for download from our Support site.

Sequence Rule Logic

Before creating your own load-ranking functions, you should understand how requests are processed by the sequence rule. When a load places a request, the load-ranking function gives the request a ranking value. The ranking value never changes.

For example, suppose a sequencing rule ranks requests based on the time remaining until due date. At 1 p.m. today a load with a due date at 4 p.m. today places a request and is given a ranking value of 3. At 3 p.m. today, a load with due date at 5 p.m. today places a request and receives a ranking value of 2. Assume that these are the only requests in the queue. Suppose that one of these requests is satisfied at 3:30. The request that is satisfied is the one with ranking value of 2, even though it has 1.5 hours until it is due and the request with ranking value 3 has only 0.5 hour until it is due.

Requests are ranked in the internal list representing the queue from low to high based on the ranking value. You can reverse this order in your custom logic by multiplying the ranking value by -1. For example, to rank loads based on a longest processing time for a current operation, a ranking function would return the negative of the processing time for the load at its current operation.

Naming the Function

Your custom load-ranking function can have any name that is not a standard user-callable function name.

Arguments


#include "factor.h"
double myrule(ldp, atrib)
LOAD       *ldp;  /* pointer to the load. */
ATTRIBUTE  *atr;  /* pointer to attribute, if any, to base ranking on. */

The function must accept two arguments in the following order:

  • A load (Type: LOAD*).
  • An attribute (Type: ATTRIBUTE).

Return Value

The function must return a value (Type: double) which is the ranking value of the load's request.

Here is an example of a load-ranking function to order loads based on least dynamic slack (that is, the least remaining time to due date minus the remaining processing time):


double sqrl (LOAD *ldp, ATTRIBUTE *atr)
/*-----------------------------------------------------------------
  Ranking function to cause loads to be ranked on a least dynamic
  slack basis.
     ARGS:
       ldp - pointer to load for which to evaluate the ranking code
     RETURNS: load ranking value
-----------------------------------------------------------------*/
{
     double rt, lt;
     int rn;
     rt = sermot(ldp, &rn, <);
     return(ldp->loordp->ordudt - DATENOW - rt);
}

Installing the Custom Function

To make your custom function available to the Scheduler, you must "install" it from the initialization function ucini1 by calling the function sedfrk. Sedfrk has two arguments in the following order:

  • The number of the sequencing rule for which your ranking function contains custom logic.
  • The address of your load-ranking function.

For example, to install the above example rule "sqrl" in rule position 39:


sedfrk (39, sqrl);