Phase 5. Modeling CNC machines

In this part of our tutorial, we’ll simulate the CNC machines that process raw materials. We’ll start by marking up the space and using point nodes to define the CNC machine locations.
  1. On the Space Markup palette, drag the Point Node  element on to the job shop layout, and name it nodeCNC1.
  2. Copy this node to mark up the space for the second CNC machine.

    AnyLogic will name the second node nodeCNC2.

    We’ll need to create paths to connect both of these nodes to our network. Our model’s forklift trucks will need them to reach the CNC machines.

  3. On the Space Markup palette, click the Path  element and draw paths as shown in the figure below. To connect a path to a point node, click the point node’s center.

    NOTE: Make sure the paths that you draw connect the nodeCNC1 and nodeCNC2 to the network. You can test a path’s connection by clicking twice to select it. If the path is connected to the network, cyan highlights will appear around its end points.

    A CNC machine is a resource unit, and we’ll add it to our model by creating a resource type and using the ResourcePool block to define the resource pool.

  4. On the Process Modeling Library palette, click and drag the ResourcePool  block onto the Main diagram.
  5. In the ResourcePool block’s Properties area, do the following:
    1. In the Name box, type cnc.
    2. In the Resource type list, click Static to reflect the fact this is a static resource.


    With our resource pool complete, we’re ready to create a new resource type.

  6. Under the New resource unit list, click the create a custom type link.
  7. In the New agent wizard, do the following:
    1. In the Agent type name box, type CNC.
    2. Click Next.
    3. On the next page of the wizard, expand the last section (CNC Machines), and select CNC Vertical Machining Center 2 State 1.
    4. Click Finish.
  8. Close the new CNC type’s diagram and return to the Main diagram.
  9. In the cnc ResourcePool block’s Properties area, do the following to place our model’s two CNC machines at the places defined by our point nodes, nodeCNC1 and nodeCNC2
    1. In the Capacity defined list, click By home location.

      The By home location option sets the number of resources equal to the number of home location nodes that you set for this resource pool.

    2. Click the plus button  and then add nodeCNC1 and nodeCNC2 into the Home location (nodes) list.

      After you’ve added the nodes, the list should resemble the figure below.

We’re ready to modify the flowchart our model uses to define the pallets’ behavior by adding a Seize block that will seize a CNC machine. Later, a Delay block will simulate a CNC machine’s processing of raw materials and a Release block will release a CNC machine so it can process the next pallet’s raw material.

NOTE: Remember that our model’s flowchart already has a pickRawMaterial block that simulates the moving resource (the forklift trucks) that delivers pallets to the CNC machine.

  1. In the flowchart that defines the pallets’ behavior, drag the pickRawMaterial and sink blocks to the right to make space for a new block.
  2. On the Process Modeling Library palette, drag the Seize  block, and insert it in the pallets’ flowchart after the rawMaterialinStorage block.

  3. In the Seize block’s Properties area, do the following:
    1. In the Name box, type seizeCNC.
    2. Under the Resource sets option, click the plus button , and then click cnc.

      Completing this step ensures the Seize block will seize one resource from the cnc resource pool.

  4. In the pickRawMaterial flowchart block’s Properties area, do the following:
    1. In the Destination is list, click: Seized resource unit.
    2. In the Resource list, click cnc.

      This block will simulate how the pallets are transported to the seized CNC machine rather than the forklift trucks’ parking zone.

  5. Do the following to simulate the CNC machine’s processing of raw materials:
    1. Add a Delay  block, place it immediately after pickRawMaterial, and name it processing.

  6. In the Delay block’s Properties area, do the following:
    1. In the Delay time box, type triangular(2,3,4) and select minutes from the list on the right.
    2. Select the Maximum capacity check box to allow the machines to process several pallets.

      Each agent that arrives to the Delay block must have one of our model’s two CNC machines.

  7. On the Process Modeling Library palette, drag the Release  block on to the pallets’ flowchart and place it after the processing block.
  8. Name this Release block releaseCNC.


    If you run the model, you’ll see that while the processes are simulated correctly, the 3D animation draws a pallet in the middle of the CNC machine shape. This occurs when the CNC machine, the pallet it is processing, and the animation location all use the same point node. To resolve the problem, we’ll need to shift the CNC machine to the right and rotate it to face the pallet.

  9. In the Projects view, double-click the CNC agent type to open its diagram.
  10. Move the animation to the right, and rotate the CNC machine shape by using the round handle or setting the figure’s Rotation property to 90 degrees.

We are ready to use two similar 3D animation shapes to animate the CNC machine: one shape will represent the idle machine and the other will represent the machine as it processes the raw materials. We’ll define dynamic values for each shape’s Visible property that will allow our model to use the CNC machine’s state to determine which shape the model will display at runtime.

  1. Do the following to change the CNC animation shape’s visibility setting:
    1. Select the CNC animation shape.
    2. Hover your mouse over the static parameters icon that displays  next to the Visible label and click Dynamic value.


      The icon  changes to a dynamic properties icon  and a box where you can define the value's dynamic expression displays. You can use the box to enter Java expression that returns a true or false value.

    3. In the box, type isBusy().

      This standard function for an AnyLogic resource returns true when the resource is busy. In our case, the function will make the 3D animation shape display when the CNC machine is processing raw materials.

Dynamic properties

When you define an expression for a property’s dynamic value, our model will reevaluate the expression on every animation frame during runtime, and then use the resulting value as the property's current value. Providing dynamic values for a shape’s position, height, width, or color allows AnyLogic users to animate their models. 

If you do not enter a dynamic value, the property retains the default static value throughout the simulation.

  1. Do the following to add one more animation shape that will be visible only when the CNC machine is not processing raw materials.
    1. Open the 3D Objects palette that has AnyLogic’s ready-to-use 3D objects.
    2. Expand the CNC Machines area and drag the CNC Vertical Machining Center 2 State 2 shape on to the CNC diagram.
    3. Rotate the shape and place it directly on top of the first animation figure.
    4. In the Visible box, switch to the dynamic value editor, and type isIdle() as the dynamic expression for the shape’s Visible property.
  2. Expand the 3D Objects palette’s People section and drag the Worker shape on to the CNC diagram.

  3. Run the model and observe the process.

    You’ll see how forklift trucks transport palets to CNC machines for processing. You should also see animated CNC machines, changing 3D shapes depending on their state.

We have finished our simple model that simulates the manufacturing and shipping process in a small job shop. You now have a basic knowledge of AnyLogic resources and how to work with them. You also know how to use a flowchart constructed from the Process Modeling Library blocks to define process logic. Your next step might be to model how the pallets with the finished parts are moved to another storage area at the shipping dock where they will stay until they are shipped. You’ve already used the blocks that you’ll need to model this part of the process, so you may want to try adding this logic on your own.

Reference model: Job Shop - Phase 5


          Phase 4. Modeling pallet delivery by trucks