Since the CostArbitrator calls getCommand during sortOptionsByGivenPolicy, the getCommand is being called twice.
getCommand might be an expensive operation, so that's not ideal. One solution would be to cache the result of getCommand on the user end but of course that's not the best solution.
Another idea could be the following:
Instead of calling option->behavior->getCommand, Option could implement a wrapper around the behavior's getCommand. The Option class would then receive a util_caching::Cache<Command> and only actually call the getCommand of the underlying behavior if it has not been called before in the same time step.
Since the
CostArbitrator
callsgetCommand
duringsortOptionsByGivenPolicy
, thegetCommand
is being called twice.getCommand
might be an expensive operation, so that's not ideal. One solution would be to cache the result ofgetCommand
on the user end but of course that's not the best solution.Another idea could be the following:
Instead of calling
option->behavior->getCommand
,Option
could implement a wrapper around the behavior'sgetCommand
. TheOption
class would then receive autil_caching::Cache<Command>
and only actually call thegetCommand
of the underlying behavior if it has not been called before in the same time step.