Skip to content

[Feature request] towards a better Python experimental example script #2288

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

Closed
7 tasks done
nikohansen opened this issue May 17, 2024 · 2 comments
Closed
7 tasks done
Assignees

Comments

@nikohansen
Copy link
Contributor

nikohansen commented May 17, 2024

A most minimalistic example experiment looks like this

import cocoex  # experimentation module
import scipy.optimize  # to define the solver to be benchmarked

### input
suite_name = "bbob"
fmin = scipy.optimize.fmin  # optimizer to be benchmarked

### prepare
suite = cocoex.Suite(suite_name, "", "")
observer = cocoex.Observer(suite_name, "")

### go
for problem in suite:  # this loop may take several minutes or more
    problem.observe_with(observer)  # generates the data for cocopp
    fmin(problem, problem.initial_solution, disp=False)

Missing functionalities are (in order of supposed importance)

  • restarts until enough successes are observed (like here)
  • meaningful output folder name
  • batch distribution (and accepting the batch number as argument)
  • MKL bug fix?
  • timing printout
  • saving of solver output and termination flags for later investigation
  • saving of setting when called with parameters (in particular budget_multiplier)

We may have several "examples" with increasing functionality (and complexity). How many seems a good number? Currently we have two, example_experiment_for_beginners and example_experiment2 (and also example_experiment_non_anytime for benchmarking non-anytime algorithms).

@nikohansen
Copy link
Contributor Author

nikohansen commented May 28, 2024

I have the following examples now, the next generally includes the functionality of the previous.
Starting from the script with 35 lines without the file docstring and

  • restarts until enough successes are observed or the budget is exhausted (like here)
  • meaningful output folder name
  1. 65 lines (+30)
    • batch distribution and reading the batch number as script argument
    • saving of setting when called with parameters (in particular budget_multiplier)
  2. 77 lines (+12)
    • timings printout
  3. 84 lines (+7)
    • saving of solver output like the termination flags for later investigation
  4. 122 lines (+38)
    • code for multiple solvers and space to implement calling code for another solver
  5. 123 lines (+1) + file mkl_bugfix.py

For reference, the example_experiment2.py had 160 lines.

@nikohansen
Copy link
Contributor Author

nikohansen commented Jun 5, 2024

The suggestion by @brockho and @ttusar is to have a separate file for the MKL bug fix and two scripts, one with 35 lines and one with full functionality.

Name suggestion: example_experiment_simple.py, example_experiment_complete.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant