anyLogistix 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.

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

Anylogic will open with the Objects model. Let us create a new Java class which we will use to define the custom inventory policy.

  1. Right click the Objects model title to open a pop-up menu.
  2. Click the New menu item and select Java class. The New Java Class dialog box will open.
  3. Type RandomQPolicy in the Name field.
  4. Click Finish. New Java class will be created with the specified name.
    Code editor for the created class will be automatically opened.

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 the anyLogistix_lib 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, in other words we will need to override all the methods declared in this 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. Add IInventoryPolicyType interface to the created class:

  2. Now we need to define the parameters of our policy. We want to create a custom RQ policy, which means that we need to create two parameters:

    • R - Replenishment point that triggers ordering of the products.
    • Q - Quantity of products that will be ordered.

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

  3. Now we will add all the required methods for this interface with the help of autocomplete and modify them as shown on the screenshots below each method:

    • The checkInventory method checks if the available inventory level is less than the user-specified replenishment point.

      public boolean checkInventory(double arg0, double arg1, double arg2, double arg3) {
             return false;
         }

    • The getInitialStock() method returns the initial amount of available products. It is used if the overrideInitialStock () method returns true.

      public double getInitialStock() {
             return 0;
         }

    • 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 null;
         }

    • The next method specifies if the stock is infinite (true) or not (false). We will set it to not infinite (false).

      public boolean infinitiveStock();

    • Now we will define the value of the Q parameter, which will get random amount of products within the specified range.

      public double replenishmentAmount(double arg0, double arg1, double arg2, double arg3) {
             return 0;
         }

    • The overrideInitialStock() method defines if the initial stock volume must be changed (true) or not (false). If it is set to true, the getInitialStock() method will be used to set the initial amount of available products.

      public boolean overrideInitialStock() {
             return false;
         }

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. Right-click the Objects library icon in the Projects view and choose Export Library from the pop-up menu.

  2. The Export Library dialog box will open.
  3. Specify the library file name (including the full path to it) in the Library File Name edit box. You may browse for the folder where you want to store your file using the Browse button.

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

The exported library file must be placed into the anyLogistix folder.

Relocate the exported library file

  1. Copy Objects.jar to C:\Users\USERNAME\.anyLogistix\Extensions folder.

Finally, restart anyLogistix to load the new policy.

Apply the custom policy

  1. Navigate to the Inventory table.
  2. Double-click the cell in the Policy Type column to select RandomQPolicy 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?