anyLogistix
Expand
Font size

Creating Custom Inventory Policy

With the help of AnyLogic we can create custom objects, policies, algorithms used by policies that will be available in anyLogistix.

Let us create a simple inventory policy. According to this policy a random amount of product will be ordered once the inventory level drops below the defined replenishment point (R). Each facility we use with this policy will have its own replenishment point.

Create custom inventory policy

  1. Open AnyLogic from anyLogistix by clicking Extensions in the menu and selecting Create New... .

  2. Click the Policies tab in the opened dialog, check the Inventory Policy and click OK.
    The AnyLogic extensions editor will open with the selected object available in the Projects view.
  3. Double-click the InventoryPolicyTemplate Java class to open it. We will use this class to define the custom policy.

    If you see an error, use the following workaround: close the graphical editor tab of this class. Now go to the Properties view, enable and then disable the Ignore option. Try opening the class again.

Developers created Objects model for a more convenient use. It contains a number of interfaces for creating custom anyLogistix objects. The general pattern of the inventory policy is declared in the IInventoryPolicyType interface, that is stored in anyLogistix Library.

To integrate our custom inventory policy into anyLogistix we must make sure that it conforms to this particular interface and implements all the methods defined in it.
The AbstractInventoryType class, which will be used in creating this policy, is implementing the interface and provides common logic for some methods. By extending this abstract class we can easier implement all the methods declared in the IInventoryPolicyType interface.

Sadly, creating custom objects requires strong programming skills. We will guide you through the process of setting up a custom inventory policy.

Define a custom inventory policy

  1. Let us start with giving a meaningful name to the policy. Change the Inventory Policy Template annotation in the @CustomTypeClass to Random Q policy.
  2. We can see that our class extends the AbstractInventoryType class by default, so we do not have to specify that.
  3. Now we need to define the parameters of our policy. We want to have the opportunity to define a replenishment point for each facility , which means that we need to create one parameter.

    Create the replenishment point parameter r of type double and we will also specify the editor it will be using ( DoubleEditor) and its name ( R) in the anyLogistix user interface.

    @Parameter(name="R", type=EditorType.DoubleEditor) double r;

  4. Now we need to add implementation to all the required methods for this interface:
    • The checkInventory method checks if the available inventory level is less than the user-specified replenishment point.
      @Override
      	public boolean checkInventory(double currentInventory, double reservedInventory, double expectedInventory, double waitingAmount) {
      		return false;
      	}

      Modify it in the following way:

      @Override
      	public boolean checkInventory(double currentInventory, double reservedInventory, double expectedInventory, double waitingAmount) {
      		return currentInventory - waitingAmount - reservedInventory + expectedInventory < r;
      	}
    • Now we will define the amount of product to order, which will be a random value within the specified range.
      @Override
      	public double replenishmentAmount(double currentInventory, double reservedInventory, double expectedInventory,
      			double waitingAmount) {
      		return 0;
      	}

      Modify it in the following way:

      @Override
      	public double replenishmentAmount(double currentInventory, double reservedInventory, double expectedInventory,
      			double waitingAmount) {
      		return new Random().nextDouble()*90+10;
      	}
    • The getDescription() method defines the parameters of the policy that will be available in the anyLogistix user interface, namely R and Q parameters.

      public String getDescription() {
          return "No parameters";
      }

      Modify it in the following way:

      @Override
      public String getDescription() {
          return "R="+ r +", Q=random";
      }

We have completed creating our custom inventory policy. Now we need to connect the new policy to anyLogistix to make it available in the list of inventory policies.

Export the new policy

  1. Double-click the Export to ALX item in the extension tree to open the Export anyLogistix Extension dialog box.

  2. Specify the required name In the Extension File Name edit box. You may browse for the folder where you want to store your file using the Browse button. Leave the default path, unless you want to save this extension to some other folder.

    The default folder allows the exported object to be instantly available in anyLogistix.

  3. Click Finish. You will see the message dialog box informing you that the extension was successfully exported.

Apply the custom policy

  1. Navigate to the Inventory table.
  2. Double-click the cell in the Policy Type column to select Random Q Policy from the list of available policies.
  3. The Policy Parameters column will now contain the parameters of the selected policy.
  4. Define the policy parameters to start using it in your supply chain.
How can we improve this article?