Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cost arbitrator called twice #patch #77

Merged
merged 3 commits into from
Nov 19, 2024

Conversation

ll-nick
Copy link
Collaborator

@ll-nick ll-nick commented Nov 19, 2024

Closes #62

The CostArbitrator calls getCommand twice. Once in getAndVerifyCommand like all verifier types but also once in sortOptionsByGivenPolicy since the command is required to estimate the cost.
The call to getCommand can potentially be quite expensive, though. Therefore, this PR adds a cache for it inside the Arbitrator::Option class. When computing a command, the arbitrator now doesn't call the behavior directly anymore but instead calls the wrapper inside the Option class. Should the function be called two or more times inside a single time step, the cached command is returned and the behavior is not called again.

@ll-nick ll-nick requested a review from orzechow November 19, 2024 07:15
@ll-nick ll-nick self-assigned this Nov 19, 2024
Copy link
Member

@orzechow orzechow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! 👍

test/cost_arbitrator.cpp Show resolved Hide resolved
@ll-nick ll-nick merged commit 53d764b into main Nov 19, 2024
1 check passed
@ll-nick ll-nick deleted the fix_cost_arbitrator_called_twice branch November 19, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getCommand is being called twice in CostArbitrator
2 participants