Skip to content

Couldn't run the Basic Example from the README #170

@weslleyspereira

Description

@weslleyspereira

Describe the Bug

I copied the basic example (https://github.com/simopt-admin/simopt?tab=readme-ov-file#basic-example) to a Python script. When I run the script, I get:

Traceback (most recent call last):
  File "basic_example.py", line 10, in <module>
    simopt.experiment_base.plot_progress_curves(
  File "python3.12/site-packages/simopt/experiment_base.py", line 3003, in plot_progress_curves
    check_common_problem_and_reference(experiments)
  File "python3.12/site-packages/simopt/experiment_base.py", line 2867, in check_common_problem_and_reference
    x0_list = [experiment.x0 for experiment in experiments]
               ^^^^^^^^^^^^^
  File "python3.12/site-packages/simopt/experiment_base.py", line 766, in x0
    return self.__x0
           ^^^^^^^^^
AttributeError: 'ProblemSolver' object has no attribute '_ProblemSolver__x0'. Did you mean: '_ProblemSolver__xstar'?

Steps To Reproduce

  1. Copy https://github.com/simopt-admin/simopt?tab=readme-ov-file#basic-example to a Python script. Make sure you put the code under the block if __name__ == "__main__":
  2. Install simopt v1.1.1 using pip
  3. Run the code.

Expected Behavior

Traceback (most recent call last):
  File "basic_example.py", line 10, in <module>
    simopt.experiment_base.plot_progress_curves(
  File "python3.12/site-packages/simopt/experiment_base.py", line 3003, in plot_progress_curves
    check_common_problem_and_reference(experiments)
  File "python3.12/site-packages/simopt/experiment_base.py", line 2867, in check_common_problem_and_reference
    x0_list = [experiment.x0 for experiment in experiments]
               ^^^^^^^^^^^^^
  File "python3.12/site-packages/simopt/experiment_base.py", line 766, in x0
    return self.__x0
           ^^^^^^^^^
AttributeError: 'ProblemSolver' object has no attribute '_ProblemSolver__x0'. Did you mean: '_ProblemSolver__xstar'?

Environment

Please provide some details about your environment to help us replicate the bug:

  • Operating System: macOS 15.6.1
  • Python Version: v3.12.11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions