Reputation: 21
Dear stack overflow community,
I am trying to create a pallet rack in AnyLogic (version 7.1.2 university), in which the number of cells, the number of levels and some other properties are set from parameters. The parameters are set up prior to model execution from the simulation page. Has anyone done that before?
In my opinion, the problem starts with the palletRack-properties that do not allow to set parameters as values but require a number ("Number of cells: 10" instead of "Number of cells: myParameter"). But there are pre-defined functions like "setNumberOfPositions(int nPositions), so that I thought I could avoid the problem by calling these functions at the beginning of the simulation (at time zero). I used the action field of an event for that.
This caused an exception that said "root: palletRack: Markup element is already initialized and cannot be modified. Please use constructor without arguments, perform setup and finally call initialize() function.".
Since I could not modify anything in the Java editor, I tried to construct a pallet rack in the event action field:
PalletRack palletRack = new PalletRack();
palletRack.setOwner(this);
[...]
palletRack.setNumberOfPositions(p_CellsInX);
palletRack.setNumberOfLevels(p_CellsInY);
palletRack.setCellWidth(p_WidthOfCell);
palletRack.setLevelHeight(p_HeightOfCell);
palletRack.initialize();
This did not throw any errors but did not built a rack either.
Additionally, I tried to add "@Override" in front of my functions.
Has anyone any ideas how I can initialize the pallet rack with parameters or override the initial values?
Obviously, I am a total beginner in AnyLogic. I would be very grateful for any advice. Thank you in advance!
Upvotes: 2
Views: 810
Reputation: 12660
It is possible but not straight forward. You need to do everything programmatically, i.e. create the pallet rack but also the line that goes through it, add them to a (new or existing) network and then initialize it all. Some dummy code to get you started below.
Note that myNetwork
is an existing network I drew manually at design time here.
Also, one tip: draw the pallet rack and line through it manually first to easily obtain all the coordinates and ensure it would work. Then, remove those and create them programmatically but with the right settings...
PS: this might not work in AL7 but it works in AL8. You might need slightly different functions for adding to presentation
myRack = new PalletRack(this, // Agent owner
SHAPE_DRAW_2D3D, // ShapeDrawMode
true, // isPublic
ground, // ground
false, // isObstacle
-2480, // x pos
1980, // y pos
0.0, // z pos
35.2*numCellsPerRackPerLevel, // length (keep constant cell width and vary rack length accordingly)
20.0, // depth
20.0, // depthR (depth of the right riack (only if type is 2 racks and 1 aisle)
50.0, // levelHeight
0., // rotation
PALLET_RACK_TWO_PALLET_RACKS, // PalletRackType
PALLET_RACK_NO_DIRECTION, // PalletRackDirection
40.0, // aisleDepth = width
40.0, // aisleRDepth (width of right aisle, only if 1 rack 2 aisles)
35.2, // cellWidth
numCellsPerRackPerLevel, // nPositions
numLevelsPerRack, // nLevels
1, // nDeep
lavender, // fillColor
dodgerBlue, // lineColor
2); // cellsBetweenLegs
presentation.add(myRack);
// this must cut through both rack's aisles
MarkupSegmentLine segment = new MarkupSegmentLine(myRack.getX()-10, myRack.getY()+30, 0.0, myRack.getX()+myRack.getLength()+10, v_IMS_Rack1.getY()+30, 0.0);
Path path = new Path(this, SHAPE_DRAW_2D3D, true,
true, true, 1.0, false, 10,
PATH_LINE, dodgerBlue, 1.0,
segment);
presentation.add(myRack);
myNetwork.add( myRack);
myNetwork.add(path);
myNetwork.initialize();
Upvotes: 1