0
votes

I'm working on a model which is similar to Product Delivery model in Anylogic where there's a population of retailers and warehouses and for each demand, the vehicles of warehouses make the delivery. I want to calculate the distance traveled by vehicles to make delivery and to calculate the cost of transport. I used DistanceByRoute method in the state. However it didn't work. However after simulation it tells me that there's an error That's the code that I put in the entry action in the state "Unloading":

FuelCost = (DistanceCalcule / 100) * ConsoFuelPerKM*(FuelPrice) + FuelCost; DistanceCalcule=(order.retailer.distanceByRoute(vehicle))*2; DistanceParcourue = DistanceParcourue + DistanceCalcule;

However after simulation it tells me that there's an error

This image in this link shows the states that i've used

this image in this link shows what I put in the state Unloading

1
You don't say what "it didn't work" means. What outcome were you expecting and what did you get? Also, what error did you get and how did you only get an error "after simulation"? (Did you run the experiment despite there being an error identified during the model build?) - Stuart Rossiter
When I write codes in the state "unloading" in order to calculate the traveled distance and then the fuel cost, I get error after simulation, I didn't understand why it didn't work ! the pictures below (in the answer below) show where I wrote the code and what happened after simulation - Chloe

1 Answers

0
votes

So the error did occur during the run (and such errors --- Java exceptions --- always stop the run).

The Console messages allow you to click the blue text to go to the offending lines of code. It being a NullPointerException most likely means (from what you posted) that your warehouse variable was null when you tried to call distanceByRoute on it.

Why this happened depends on the rest of your model logic.