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

Feature/reward #152

Merged
merged 8 commits into from
Jun 7, 2021
Merged

Feature/reward #152

merged 8 commits into from
Jun 7, 2021

Conversation

3rdCore
Copy link
Collaborator

@3rdCore 3rdCore commented Jun 4, 2021

This is my proposition to simplify the use of struct of subtype LearningPhase
The Phase argument called by valueselection heuristic is no longer a element of type ...Phase <: LearningPhase but simply the Type ...Phase itself. That saves an allocation at each step of the search.

I also fixed a little bug on the plotRewardVariation function.

@3rdCore 3rdCore requested a review from PierreTsr June 4, 2021 23:23
Comment on lines +21 to +32
if symbol == :Infeasible
lh.reward.value -= 10*model.statistics.numberOfNodes

elseif symbol == :FoundSolution
lh.reward.value -= 1

elseif symbol == :Feasible
lh.reward.value -= 1

elseif symbol == :BackTracking
lh.reward.value -= 1
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Finally we don't need to declare another function : function set_reward!(::SolutionFoundPhase, ... as the information about the search ( :SolutionFound, :Feasible, :BackTracking ) is already contained in the argument symbol.

We simply need to inform the user that he could implement a reward that can consider different symbols.

Comment on lines -123 to -131
"""
set_metrics!(PHASE::T, lh::LearnedHeuristic, model::CPModel, symbol::Union{Nothing, Symbol}, x::Union{Nothing, AbstractIntVar}) where T <: LearningPhase

Call set_metrics!(::SearchMetrics, ...) on env.search_metrics to simplify synthax.
Could also add it to basicheuristic !
"""
function set_metrics!(PHASE::T, lh::LearnedHeuristic, model::CPModel, symbol::Union{Nothing, Symbol}, x::Union{Nothing, AbstractIntVar}) where T <: LearningPhase
set_metrics!(PHASE, lh.search_metrics, model, symbol, x::Union{Nothing, AbstractIntVar})
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this block of code was simply an interface between LearnedHeuristic and search_metrics

@3rdCore 3rdCore merged commit 1ce8b3d into master Jun 7, 2021
@PierreTsr PierreTsr deleted the feature/reward branch June 22, 2021 15:00
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.

1 participant