Simio Forum

# Vehicle Incuring Charges per Miles Traveled

## Recommended Posts

Rather than having my vehicles incur costs based on the number of riders or the unit time to transport entities, I want my vehicles to incur costs based on the number of miles traveled. Is this possible in Simio and how would I do this?

##### Share on other sites

Use totaldistancetraveled function of vehicle object to return the distance that the vehicle traveled (i.e., vehicle1[1].totaldistancetraveled). Then, simply muliply this expression with a cost coefficient you specified per distance (i.e., vehicle1[1].totaldistancetraveled*costmultiplier). u can define cost coeffient as a property of the model or vehicle or even directly enter a constant numeric value manually (although not recommended) for it. You can observe how the value of vehicle1[1].totaldistancetraveled*costmultiplier updated dynamically as the travelled distance increases.

Edited by Guest
##### Share on other sites

You might also look at the SimBit Electric Vehicle for some examples. That tracks battery level related to movement, but a similar approach could be used for cost.

##### Share on other sites
• 2 weeks later...
Use totaldistancetraveled function of vehicle object to return the distance that the vehicle traveled (i.e., vehicle1[1].totaldistancetraveled). Then, simply muliply this expression with a cost coefficient you specified per distance (i.e., vehicle1[1].totaldistancetraveled*costmultiplier). u can define cost coeffient as a property of the model or vehicle or even directly enter a constant numeric value manually (although not recommended) for it. You can observe how the value of vehicle1[1].totaldistancetraveled*costmultiplier updated dynamically as the travelled distance increases.

Thank you. In my model, the charges incurred should be specific to each path that a vehicle travels on. So, the cost multiplier in my expression for that function should be different depending on which path the vehicle is traveling on. I have attached my model. For example, for vehicles traveling from EaglePassDCb to StrathmoreDC, the cost multiplier needs to be 2.65. But for vehicles traveling from EaglePassDCb to QuincyDC, the cost multiplier needs to be 1.95. Is there a way to set this up? Also, I am not sure what kind of function or property I should be creating this expression within and how this function or property will be defined within my vehicle's properties.

MeganVasshCurrentModel - Copy.spfx

##### Share on other sites

You need to subclass the path object from standard library then define a real property named for example "Traveling Cost". Then, traveling cost calculations for each path takes place. For this, one way you should calculate each path's traveling cost indivually then sum them up as TOTAL Vehicle Traveling cost. I will look your model and try to show you the other way (relatively simple and eliminates some arithmetic operations) on your model at my best free time.

##### Share on other sites

I have included the required logic into your model. Note that this logic needs to be fine tuned perhaps further improvements required should be made accoding to your aimed statistics. Now you need to populate your model by using new subclassed vehicle and path objects. Replace the older ones (both paths and vehicle) with suclassed counterparts by dragging new objects from project library to the facility layout. let me know if you need further help...

Edited by Guest
##### Share on other sites

I have included the required logic into your model. Note that this logic needs to be fine tuned perhaps further improvements required should be made accoding to your aimed statistics. Now you need to populate your model by using new subclassed vehicle and path objects. Replace the older ones (both paths and vehicle) with suclassed counterparts by dragging new objects from project library to the facility layout. let me know if you need further help...

MeganVasshCurrentModel.spfx

##### Share on other sites
I have included the required logic into your model. Note that this logic needs to be fine tuned perhaps further improvements required should be made accoding to your aimed statistics. Now you need to populate your model by using new subclassed vehicle and path objects. Replace the older ones (both paths and vehicle) with suclassed counterparts by dragging new objects from project library to the facility layout. let me know if you need further help...

Very helpful, thank you! I have subclassed MyPath and MyVehicle and created the real property, TravelingCost, and overridden the required logic. I have replaced all vehicles with subclassed counterparts and have began to replace paths as well. When I run the model, I have come across an error. I have attached a snippet of the error and have attached my model. Do you have any clue as to what is causing this error? Thank you in advance!

MeganVasshCurrentModel - Copy.spfx

##### Share on other sites

You had better collect the transportation cost and total tranportation cost on myvehicle object. I attached revised version of your model.

MeganVasshCurrentModel - Copy.spfx

##### Share on other sites
You had better collect the transportation cost and total tranportation cost on myvehicle object. I attached revised version of your model.

Great, thank makes sense. My model is running without error now. The next step I need to take is to set the cost multiplier for each path. I am unclear how to go about this. I am thinking I will be duplicating the property PathTravelingCost within MyPath object for each path and setting the cost multiplier for each. Is this the right way to go about it or where will I need to enter the cost multiplier for each path?

##### Share on other sites

Absolutely right. We have already defined a real type property for Mypath object for this purpose. And, we used this propert while calculating costpertransportation (see assign 11 of on reachedend process of mypath object). So you only need to enter the values of cost multiplier for each path by entering indiviual values of PathTravelingCost property of each mypath object. Select each mypath object from facility layout and see this property under "general" category of mypath object.

##### Share on other sites
Absolutely right. We have already defined a real type property for Mypath object for this purpose. And, we used this propert while calculating costpertransportation (see assign 11 of on reachedend process of mypath object). So you only need to enter the values of cost multiplier for each path by entering indiviual values of PathTravelingCost property of each mypath object. Select each mypath object from facility layout and see this property under "general" category of mypath object.

Perfect. I have set the cost multiplier for each path that my SteelTruck will travel on. How will I view the total transportation cost that we have created the state variable ModelTotalTransportationCost for? It currently doesn't show up anywhere in my results after a run.

Also, for the many paths that link servers directly to sinks (the paths which my BoomTruck travels on), I am looking for a way around replacing each of these paths with subclassed objects from MyPath. These paths are each charged at the same rate of 1.82 per mile so there is no need to go in and set a different PathTravelingCost for each one.

I am thinking I need to set a real property for BoomTravelingCost under MyVehicle object and this will allow me to specify the BoomTravelingCost within the general properties for each vehicle in my facility layout. I am unsure of how to correctly adjust the processes with MyVehicle object to include this BoomTravelingCost. This would be similar to what we did for the MyPath object in creating the PathTravelingCost property and editing the OnReachedEnd process to include this.

##### Share on other sites

First you have to define a cost center for your model. Select definitions tab then elements and click cost center from the ribbon. Then Process 1 is defined to be triggered by all vehicles "entered node" add-on process. I assumed that all vehicles charged transportation cost if they are transporting entities. Otherwise, no cost is added to costcenter1 of model. For the the second topic you mentioned simply set "PathTravelingCost" property's default value to 1.82. This value will appear as default whenever you place a mypath object to the facility layout. This can save time and energy. Browse the attached model.

Note: Related to second topic you also can right click on any mypath object then select "open properties spreadsheet view of this type of object" from the menu. This will allow you to type in cost values manually. Also, this spreadsheet view enables you to copy values from excel spreadsheet. First, prepare the template (populate excel cells with the values) then simply copy and paste it to Simio. This will simplify editing process.

MeganVasshCurrentModel - Copy.spfx

##### Share on other sites
First you have to define a cost center for your model. Select definitions tab then elements and click cost center from the ribbon. Then Process 1 is defined to be triggered by all vehicles "entered node" add-on process. I assumed that all vehicles charged transportation cost if they are transporting entities. Otherwise, no cost is added to costcenter1 of model. For the the second topic you mentioned simply set "PathTravelingCost" property's default value to 1.82. This value will appear as default whenever you place a mypath object to the facility layout. This can save time and energy. Browse the attached model.

Note: Related to second topic you also can right click on any mypath object then select "open properties spreadsheet view of this type of object" from the menu. This will allow you to type in cost values manually. Also, this spreadsheet view enables you to copy values from excel spreadsheet. First, prepare the template (populate excel cells with the values) then simply copy and paste it to Simio. This will simplify editing process.

Great, using the spreadsheet view made it MUCH easier to replace and edit my paths. I have added the cost center and defined Process1 but am still not able to view the total cost. I created a status label just as you did but mine will not increase in value when I run my model. I have attached my model, when you have a moment could you look at mine and see if you can tell what I did wrong? I compared your model to mine but can not seem to find any differences. Thank you!

MeganVasshCurrentModel - Copy - Copy.spfx

##### Share on other sites

In fact your model works properly. But, if you did not intentionally leave it so, mypath1's pathtraveling cost is not assigned a value (i.e., not >0). So, a cost value is calculated but it always be zero. Thus, you can not see any change in your status label. If it is forgotten you should check other paths as well. Also, all vehichle's except steel truck's "loaded" add-on process leaved blank. Is it right? else you should set theirs proper values as well.

##### Share on other sites
In fact your model works properly. But, if you did not intentionally leave it so, mypath1's pathtraveling cost is not assigned a value (i.e., not >0). So, a cost value is calculated but it always be zero. Thus, you can not see any change in your status label. If it is forgotten you should check other paths as well. Also, all vehichle's except steel truck's "loaded" add-on process leaved blank. Is it right? else you should set theirs proper values as well.

Ahh I see, okay I have set the PathTravelingCost for the ones left blank. However, I have intentionally left blank the add-on process for all other trucks because these trucks are meant to drop off the load at the first node they reach so this add-on process is not necessary for them.

I have gotten my status label to work and display the transportation cost. However, the number that is being displayed seems to be much larger than it should be. For example, in the screenshot I've attached, the first truck that leaves the source and travels on MyPath1 to Customs should incur a cost of \$308.00 (the path's length of 154 miles multiplied by the PathTravelingCost of \$2.00. However, once the vehicle reaches the end of MyPath1, the number in the status label displayed is much larger. Am I reading this correctly or did I possibly mess up the logic within my processes somewhere?

MeganVasshCurrentModel-Test.spfx

##### Share on other sites

Because simio calculates vehicle.totaldistancetravelled function as meters (154 mile=247838,... meters). Thus, you should divide vehicle.totaldistancetravelled function by 1609,344. Focus mypath object's assign 10 step. I also included a status label to show how the conversion operation in assign 10 step managed to give expected cost. Note that status label still shows the distance travelled per meters but the cost is calculated per mile.

MeganVasshCurrentModel-Test.spfx

##### Share on other sites
Because simio calculates vehicle.totaldistancetravelled function as meters (154 mile=247838,... meters). Thus, you should divide vehicle.totaldistancetravelled function by 1609,344. Focus mypath object's assign 10 step. I also included a status label to show how the conversion operation in assign 10 step managed to give expected cost. Note that status label still shows the distance travelled per meters but the cost is calculated per mile.

Ahh, this makes sense. I have converted the cost calculated to miles. However, my total system cost is still off by \$3-\$4 million of what I expect it to be. I think I have figured out this is because my entities route out from outbound nodes at the servers by link weight. How accurate can I expect this to be?

For example, entities traveling from Customs to either EaglePassDCa or EaglePassDCb are routed out by link weight. Selection weight for the path to DCa is 27.456 and DCb is 72.544. Since I have a maximum of 1993 arrivals, there should be 547 that are processed through DCa and 1,446 that are processed through DCb. However, whenever I run my model, there are 572 processed through DCa and 1421 processed through DCb. Any idea why this number is not more accurate? I have attached my updated model

MeganVasshCurrentModel-CurrentVersion.spfx

##### Share on other sites

This is not related with the logic of your model but an issue of randomness or uncertainity. You can get the values you expected either at the long run or running many replications and average the response values over those replications. In your situation, you got those values at the end of ONLY ONE replication in the facility view of simio. In the attached pdf file I showed where you can set the specific replication number to get the response values for that specific replication. You have to run many replications to converge the expected (theoretical) values. But, in facility view you are allowed only one replication to run. And, fortunately you are allowed to run many many replications by defining an experiment for the model you developed.

In order to get average values of responses over many replications you should define an experiment from "Project Home" ribbon--> and "New Experiment". I defined an experiment and added EaglePassDCa.Processing.NumberEntered value as a response. I set the required replication number to 1000, a very big number. See how the value of EaglePassDCa.Processing.NumberEntered converges to its "true" value as the replication number increases (547,037 a very very close value to the expected value). You can test smaller values for replication number (set required replication number to 10 and see the average value of EaglePassDCa.Processing.NumberEntered) and see how the lower values could be misleading. Thus, in simulation studies you need to consider how many replications you have to make for your purposes to achieve ofcourse with a margin of error. You should refer to a simulation book for more information on this topic.

MeganVasshCurrentModel-CurrentVersion.spfx

MeganVasshCurrentModel-CurrentVersion.pdf