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

Return of status #71

Open
weihevt opened this issue Oct 29, 2020 · 8 comments
Open

Return of status #71

weihevt opened this issue Oct 29, 2020 · 8 comments

Comments

@weihevt
Copy link

weihevt commented Oct 29, 2020

Hi, I am wondering how can I get the status from the result variable, is there a function call on result and return the status: success or failure? Thanks.

@wildart
Copy link
Owner

wildart commented Oct 29, 2020

converged(result)

@weihevt
Copy link
Author

weihevt commented Oct 29, 2020

Thanks. But converged(result) only give true or false. I would like get the information when I type result and hit enter in Julia REPL, it show the reason why the algorithm stop, e.g. Status: success or Status: failure (reached maximum number of iterations). How can I get this information?

@wildart
Copy link
Owner

wildart commented Oct 29, 2020

Look at the OptimizationResults interface, you may find what you need there.

@weihevt
Copy link
Author

weihevt commented Oct 30, 2020

Thanks a lot. I tried them. I would like to know why the algorithm stop, but looks no one works.

@wildart
Copy link
Owner

wildart commented Oct 31, 2020

I would like to know why the algorithm stop

That would depend on a problem you're trying to solve. I assume you didn't get a desired result which prompted this issue. There are many things that affect the outcome of the optimization: choice of algorithm, its initial conditions & parameters. Depending of the parameter combination, the performance of the algorithm can widely vary.

I can only comment on the mechanics of termination condition. There are two termination conditions: a) the algorithm ran over specified number of the iterations, and b) the algorithm reached the specified tolerance level. In any case, you first check if the algorithm converged with converged(result). Then:

  • Option (a): You can check this case by running iteration_limit_reached(result). The result will tell if you reached the iteration limit (it's specified in options).
  • Option (b): There are two tolerance thresholds - absolute and relative. If the absolute/relative difference in the result between the iteration is lower then the specified threshold then the algorithm terminated. In addition, there is an option successive_f_tol which allow to continue computation for the specified number of iterations in this option after the algorithm reached either tolerance level. iterations(result) returns the number of passed iterations till the algorithm converged.

In addition, you may want to setup the trace to gather information about the optimization process which may give you more insights. See tests for examples.

@wildart wildart closed this as completed Oct 31, 2020
@wildart wildart reopened this Oct 31, 2020
@weihevt
Copy link
Author

weihevt commented Oct 31, 2020

Thanks a lot for the kind explanation. I can get a desired result at most of the time. The reason I would like that it returns some information because at some specific settings, e.g. different iterations or I selected a weird parameter range, the algorithm fails. I do this specific setting in a for loop, so I would like it return something and I can print in the loop.

By your help, I add the converged(result), iteration_limit_reached(result) and tol(result).
I have one more question, if converged(result) is true, it means the algorithm is success and iteration_limit_reached(result) is false. And if converged(result) is false, it means that the algorithm is failed for what ever reason?

@wildart
Copy link
Owner

wildart commented Oct 31, 2020

so I would like it return something and I can print in the loop.

The debug trace can be enabled through the the show_trace parameter in the Options object, see here https://wildart.github.io/Evolutionary.jl/dev/tutorial/#General-options-1.
For more detailed trace specify a trace function.
See also how it's done in here https://github.com/wildart/Evolutionary.jl/blob/master/test/onemax.jl

I have one more question, if converged(result) is true, it means the algorithm is success and iteration_limit_reached(result) is false.

That means you reach some minimum within the specified number of the iterations, which is a good thing. But you need to inspect the solution in case if it's a local minima.

And if converged(result) is false, it means that the algorithm is failed for what ever reason?

It could be the case, but it depends on a problem setup. Maybe the optimal solution was found but your tolerance level is too low, so the algorithm continues to refine it, and unable to do that in the specified number of the iterations. Or the optimization on the right track to discover the optimal solution, but the changes in the population are small, and so it take more iterations of the algorithm to reach the global minimum. You need to experiment with various parameters and verify the result at the end.

@weihevt
Copy link
Author

weihevt commented Oct 31, 2020

Thanks for the kind explanation. I got the idea.

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

No branches or pull requests

2 participants