I get a NullPointerException error in this scentence in my Anylogic model:
if (directRoute.routeCosts.get("Day") < toHubRoute.routeCosts.get("Night") fromHubRoute.routeCosts.get("Day")) {
This scentence is located within this function where the cheapest route should be found (to drive directly or via hub located in Region102), for every order that has to go from a certain terminal to certain customer.
The function is referring to the routes and costs of the following list:
The data sets for routes and costs are:
Does anybody know why I get this error and how to fix it?
Thank you!
CodePudding user response:
It means that at that point of simulation either directRoute.routeCosts.get("Day")
or toHubRoute.routeCosts.get("Night")
or fromHubRoute.routeCosts.get("Day")
does not exist.
It might potentially happen due to the following reasons:
- Route does not exist at all
- Having a look at your first screenshot, you check connections from
"Region102"
. Are you doing that deliberately? - Having a look at your second screenshot, you say
where (cost.route.eq(route.id))
, isroute.id
column defined or given as input?
PS. The issue was that in the second screenshot, it should be costRow.get
, not row.get
.