AnswerHub Upload Issue
Our AnswerHub community currently has a bug that prevents you from attaching your model or other files to your questions. AnswerHub is aware of this issue and they are working on a fix. Until we receive their patch, you can upload your models and other files to FlexSim's file share site. Include the file name in your question so that we know which upload to reference.


C avatar image
C asked Felix Möhlmann commented

Questions about logging state changes, calculating energy consumption

Hi all,

There is a model I'm working on. I'm using the virtual distance feature for paths. There are AGVs (ships) loading crates from a "dock" and unloading them at another "dock". And I need to introduce an energy consumption and recharging calculation so that each AGV,

1) If they are in "Travel Loaded" state, they must spend some energy per unit of distance (e.g., 3000 units of energy stored onboard, consumes x units of energy per unit of distance (Please note that there will be four types of AGVs (ships) with different rates of energy consumption when this study finishes),

2) If they are in an "Idle" state and if their "Loc" labels are set to a particular "dock" (e.g., BOS, KSK, ALS or KSK1, and so on), they must gain energy at an adjustable rate. (e.g. y units of energy per second),

3) The energy values of each AGV must be logged and visualized.

Bonus step: Visualasing distances traveled (as they increase) and state changes of AGVs for each AGV in two seperate time plots with timestamps would be great.

I think I need to define variables about energy, but I don't know how to.

Sorry but I'm stuck. I feel stupid for not fixing this and ashamed of taking peoples' time.

Any help will be appreciated.


FlexSim 19.0.0
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Hi @C, was Felix Möhlmann's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Felix Möhlmann commented

If you were using AGV paths, you could use the built in battery system for this. But since they don't offer the same virtual distance property as network nodes (as far as I'm aware), they don't seem to be an option.

You can build your own system though. Define a kinetic tracked variable on each agv that serves as the battery level. Three more labels define the charge/discharge rate and the maximum charge the battery can hold, so these can be set differently for the different types.

In the attached model I use an instanced process to listen to the state changes of the agv and adjust the rate at which the tracked variable changes when it switches to "travel loaded" or "idle". A statistics collector listens to these activities and logs the current value whenever the rate changes (since the rate is linear, the graph only needs to know those data points).

The rate of a tracked variable is of course by time rather than distance but since the speed is going to be near constant due to the large distances the error seems negligible.


The function is only added to F3 and F4 so far.

· 9
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Thank you so much. I've studied what changes you have made and I get it now. You need to make a Custom Code, define variables and track them in order to get battery, consumption and recharging possible. I expanded it onto F1 and F2. I will expand it all AGVs.

Now I want to limit where charging is available and at what rate. For example, it is possible to setup a zone around BOS and when a ship enters that zone, it's charging rate changes to a value?

Also, is there an easier way to adjust the Battery, dischargeRate, chargeRate,and maxCharge values like setting labels and values for group members at the beginning of the sim? I know how to set labels but couldn't figure out how to set a tracked kinetic level label for a group. Do I set the label first for the group and then make them tracked somehow? I have done it manually for all AGVs for it would be a lot easier to experiment with capacities.


0 Likes 0 ·

The only way to have "zones" around the locations where the travellers are charged would be to place intermediate network nodes around them. Then you can react to a task executer travelling over them and set the battery rate depending on the direction they travel ("toEdge").




You can select multiple objects by holding down "shift" and dragging a box around them or holding "ctrl" and selecting them one by one. Then you can use the buttons in the bottom right corner of the label tab to copy labels from the highlighted object to all of them.



1 Like 1 ·
1642009043667.png (48.0 KiB)
1642010115819.png (21.4 KiB)
1642010131438.png (9.2 KiB)
1642010261416.png (53.8 KiB)
1642010291502.png (7.5 KiB)
C avatar image C Felix Möhlmann ·
Thank you! Can you please share the model as well?
0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.