简体   繁体   中英

How to rate units in a Resource Pool and select the highest rated unit in the seize block?

I am doing a simulation project of a logistics system. I created an agent named " AGV " with a variable " power "and I have a Resource Pool of it. I want to use the " Unit with top rating " in the " Resource Selection " of the Seize block to preferentially select the AGV with the lowest power.But when I type in " 1/unit.power " in " Unit rating ", the system reports an error. It seems that I cannot call the variable " power " located in the " AGV " agent. How can I solve this problem, or is there any other way to achieve my purpose.

unit is of type agent and you have to cast it as type AGV... Or whatever your type is for your agent AGV... use lowercase for populations or agents and use Uppercase first letter for classes or Agent types... That's notation standards..

Now let's assume your agent type is called AGV... be sure you use the correct type...

Then use 1.0/((AGV)unit).power

Then use 1.0 because if your variable power is an int you will have problems, if it's a double it's all good.

But let's hope you don't have power=0... because if you do, then maybe it's better to do:
-((AGV)unit).power instead, otherwise it's fine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM