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

Entire refacto of search metrics #141

Merged
merged 57 commits into from
May 28, 2021
Merged

Entire refacto of search metrics #141

merged 57 commits into from
May 28, 2021

Conversation

3rdCore
Copy link
Collaborator

@3rdCore 3rdCore commented May 26, 2021

This is my proposition for the implementation of a generic and adaptable metrics to store many useful pieces of informations and results obtained during the search, such as the number of nodes visited for every solution for every episode during the training, the time needed to complete a search on an episode...

Previously, the metrics had to be defined by the user while creating his model. This was not relevant as the retrieved results don't depend on the kind of problem ( be it knapsack, graph coloring ... ) addressed by SeaPearl.

By using the abstract struct : AbstractMetrics the user can define his own CustomMetrics as long as it satisfies some requirements. This PR also provides a basicmetrics that can be used out of the box.

This PR goes in hand with an another PR on SeaPearlZoo that will update the current examples (knapsack, graph_coloring, tsptw) to fit this new format.

Key features :

  • basicmetrics can be used on any kind of CPModel (containing an objective or not )

  • basicmetrics can be used on any kind of heuristic ( classic or trained )

  • basicmetrics provides useful plotting functions : ( evolution of nodes visited to find a first solution / prove the optimality along the training, evolution of score of solutions found compared to the optimal one during the search during an evaluation.

  • Evolution of nodes visited to find the first solution / prove the optimality along the training : ( for illustration purpose, no noticeable learning can be observed )
    Capture d’écran du 2021-05-26 18-30-33

  • Evolution of score of solutions found compared to the optimal one during the search during an evaluation :
    Capture d’écran du 2021-05-27 11-30-56

@3rdCore 3rdCore added the enhancement New feature or request label May 26, 2021
@qcappart
Copy link
Collaborator

Seems to be a great enhancement !

Few questions/concerns:

  • The checks have failed. I guess it is due to a mismatch with the previously accepted PR Feature/disjunctive #139
  • I am not sure to understand the last picture. What are the different curves ?
  • Also, I would be interesting to have a native support on the evolution of the best known solution so-far during the search. I.e., the number of nodes visited in the x axis, the the solution value on the y-axis.

@3rdCore
Copy link
Collaborator Author

3rdCore commented May 27, 2021

Sorry for giving not enough details yesterday, I wanted to clarify some parts this morning, and embellish the plot.

The checks have failed. I guess it is due to a mismatch with the previously accepted PR #139 

-> I have identified a small bug on the testset. I will add a fix on my last commit.

 I am not sure to understand the last picture. What are the different curves ?

-> The first 2 subplots represent the rolling average of : the nb of nodes visited to prove optimality and the nb of nodes visited to find the first solution. ( the rolling average is used to smooth the results due to disparities between solved instances. )
The second plot represents the evolution of the best-known solution so far during the search for different search during the training. ( episode 100,200,300 ... ) the aim is to see the area diminish as the research progress. The plotted score is a relative score of solutions compared to the optimal ( it goes from 0 to 1 ).

Also, I would be interesting to have a native support on the evolution of the best known solution so-far during the search. I.e., the number of nodes visited in the x axis, the the solution value on the y-axis.

-> This is the second plot.

@qcappart
Copy link
Collaborator

Ok thanks ! I understand the last picture. We should find a way to reduce the number of curves. For instance, we can add a parameter defining each "how many" episode a new curve must be plotted.

Also, in practice, it may be difficult to have the relative score, as it requires to know the optimal solution. Maybe we can change it with the relative score to the best solution found. Also, it could be interesting to have a measure of the "raw value" of the objective.

Copy link
Contributor

@PierreTsr PierreTsr left a comment

Choose a reason for hiding this comment

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

Some minor modifications are still needed (mainly on naming conventions and documentation). But this is an amazing improvement to bring more insights on SeaPearl performances.

src/RL/utils.jl Outdated Show resolved Hide resolved
src/experiment/evaluation.jl Outdated Show resolved Hide resolved
src/experiment/metrics/basicmetrics.jl Outdated Show resolved Hide resolved
src/experiment/metrics/basicmetrics.jl Outdated Show resolved Hide resolved
src/experiment/metrics/basicmetrics.jl Outdated Show resolved Hide resolved
src/experiment/metrics/basicmetrics.jl Outdated Show resolved Hide resolved
src/experiment/metrics/basicmetrics.jl Outdated Show resolved Hide resolved
src/experiment/metrics/basicmetrics.jl Outdated Show resolved Hide resolved
src/experiment/metrics/metrics.jl Outdated Show resolved Hide resolved
src/experiment/metrics/metrics.jl Outdated Show resolved Hide resolved
@qcappart
Copy link
Collaborator

Good to me ! (provided that the last build passes :-)

I am very eager to see these plots on the next experiments on the learning !

@sandertom
Copy link
Contributor

I think number of nodes until first solution found is always one less than what it should be. Here, we stop the search after one solution is found. The to curves should be the same, but there is a difference of one.
exp8_3000_frw10

@3rdCore 3rdCore merged commit 88d99bd into master May 28, 2021
@3rdCore 3rdCore deleted the MetricsFun branch May 28, 2021 15:51
3rdCore added a commit that referenced this pull request May 28, 2021
@3rdCore 3rdCore restored the MetricsFun branch May 28, 2021 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants