Skip to content

Commit

Permalink
fixes a potential issue with cache and Constant expression creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaillandier committed Sep 23, 2024
1 parent d7e9d5f commit 56a49a1
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ public static Boolean readyToCross(final IScope scope, final IAgent vehicle, fin
// additional conditions to cross the intersection, defined by the user
IStatement.WithArgs actionTNR = context.getAction("test_next_road");
Arguments argsTNR = new Arguments();
argsTNR.put("new_road", ConstantExpressionDescription.create(newRoad));
argsTNR.put("new_road", ConstantExpressionDescription.createNoCache(newRoad));
actionTNR.setRuntimeArgs(scope, argsTNR);
if (!(Boolean) actionTNR.executeOn(scope)) return false;

Expand Down Expand Up @@ -2005,7 +2005,7 @@ private boolean moveAcrossRoads(final IScope scope, final boolean isDrivingRando
// Choose a lane on the new road
IStatement.WithArgs actionCL = context.getAction(ACT_CHOOSE_LANE);
Arguments argsCL = new Arguments();
argsCL.put("new_road", ConstantExpressionDescription.create(newRoad));
argsCL.put("new_road", ConstantExpressionDescription.createNoCache(newRoad));
actionCL.setRuntimeArgs(scope, argsCL);
int lowestLane = (int) actionCL.executeOn(scope);
laneAndAccPair = MOBIL.chooseLane(scope, vehicle, newRoad, lowestLane);
Expand All @@ -2029,8 +2029,8 @@ private boolean moveAcrossRoads(final IScope scope, final boolean isDrivingRando
actionOnNewRoad.executeOn(scope);

// external factor that affects remaining time when entering a new road
argsEF.put("remaining_time", ConstantExpressionDescription.create(remainingTime));
argsEF.put("new_road", ConstantExpressionDescription.create(newRoad));
argsEF.put("remaining_time", ConstantExpressionDescription.createNoCache(remainingTime));
argsEF.put("new_road", ConstantExpressionDescription.createNoCache(newRoad));
actionImpactEF.setRuntimeArgs(scope, argsEF);
remainingTime = (Double) actionImpactEF.executeOn(scope);
if (remainingTime <= 0.0) return false;
Expand Down

0 comments on commit 56a49a1

Please sign in to comment.