Required Capacity Customization Point

Modifying activity capacity profiles in a customization

This guide will step through the process of coding a Required Capacity customization. If you are just getting started, you can learn about getting started with customizations

Creating the Class

To start, we will need to create two new classes that inherit from RequiredCapacityCustomization.  This customization class is located at: PT.Scheduler.Simulation.Customizations.RequiredCapacityCustomization.

Here is what a  basic class should look like:

public class RequiredCapacityCust : RequiredCapacityCustomization
{
//Declare any objects you need in your calculations here

//Customizations must have a name
public override string Name => "Required Capacity";

//Customizations must have a description
public override string Description => "Required Capacity customization used to determine run rate.";

/// <summary>
/// Determine the setup and processing spans of an activity or change the quantity per cycle. This function is called by the
/ /// scheduler prior to attempting to schedule
/// </summary>
protected override void BeforeRequiredCapacityCalculation(long a_simClock, BaseActivity a_activity, BaseResource a_resource, ref ChangableActivityValues r_changeValues)
{
//Place code here to calculate the related run rate
}

/// <summary>
/// This function is called before the system has calculated standard setup time. If a value other null is returned, then the system will use it and
/// skip calculating setup time a second time. Null return value signifies "pass" so system will need to calculate the setup.
/// </summary>
protected override RequiredSpanPlusSetup? CalculateSetup(InternalActivity a_act, InternalResource a_res, long a_startTicks, LeftNeighborSetupValues a_leftNeighborSetupValues)
{
//Place code here to calculate the setup
}

/// <summary>
/// Adjusts the setup time. This is called after setup time has been calculated by standard means and the standard setup is passed to this function. The value returned by this function overrides the standard setup.
/// </summary>
protected override RequiredSpanPlusSetup AdjustSetupTime(InternalActivity a_act, InternalResource a_res, long a_startTicks, RequiredSpanPlusSetup a_setupSpan, LeftNeighborSetupValues a_leftNeighborSetupValues)
{
//Place code here to adjust the setup
}
}

Here we have a few functions that can be overriden to begin customizing at the required capacity customization point:

BeforeRequiredCapacityCalculation can be used to calculate the setup/processing spans or the quantity per cycle of an activity using some custom logic that is not handled by the scheduler. This function can be called multiple times before attempting to schedule an activity. It is advisable to keep this in mind when designing the custom logic. It could slow the simulation considerably.

CalculateSetup can be used to skip calculating the standard setup time of the activity and use values as calculated by the custom logic of the customization.

AdjustSetupTime is called after the standard setup time has been calculated, and can be used to modify the value.

Operation field TimeCustomizer, which was previously required for an operation to be processed in this customization point, became obsolete on Version 11.37.10

 

First let's take a look at the parameters for BeforeRequiredCapacityCalculation:

  • long a_simClock: The ticks of the DateTime the scheduler is attempting to schedule an activity.
  • BaseActivity a_activity: The activity that is attempting to schedule.
  • BaseResource a_res: The resource the scheduler is attempting to schedule on.
  • ref ChangableActivityValues r_changeValues: allows specification of which values should be changed. 

Then let's take a look at the parameters for CaculateSetup:

  • BaseResource a_res: The resource the scheduler is attempting to schedule on.
  • BaseActivity a_activity: The activity that is attempting to schedule.
  •  long a_startTicks: The activity start date time ticks.
  • LeftNeighborSetupValues a_leftNeighborSetupValues: values for the operation scheduled before the activity trying to schedule currently

Then let's take a look at the parameters for AdjustSetupTime:

  • BaseResource a_res: The resource the scheduler is attempting to schedule on.
  • BaseActivity a_activity: The activity that is attempting to schedule.
  •  long a_startTicks: The activity start date time ticks.
  • RequiredSpanPlusSetup a_setupSpan: contains information about the activity's setup
  • LeftNeighborSetupValues a_leftNeighborSetupValues: values for the operation scheduled before the activity trying to schedule currently

Next Steps

Explore the following articles to see an example of how this customization point can be used,  meet other types of scheduling requirements or to learn how to better navigate the PlanetTogether data objects explore the following articles:

 

Coming Soon...