Skip to content

Conversation

@delaossa
Copy link
Collaborator

@delaossa delaossa commented Jan 30, 2024

  • print_best_evaluations shows a table with the top scoring evaluations in the given objective.
    example:
diags.print_best_evaluations(top=5)
Top 5 evaluations in metric f1 (minimize = False):  [168, 125, 74, 47, 84]

             f1          f2         x0         x1
168  897.356441  432.315095 -41.014755  12.668375
125  806.129161  709.940631 -46.410127  11.699764
74   770.447289  616.824412 -47.631321  11.454126
47   757.891119  726.930477 -49.191153  12.272802
84   739.310092  378.713516 -35.158977  12.262404
  • print_evaluation shows the relevant parameters of a given evaluation.
    example:
diags.print_evaluation(168)
Evaluation 168: 
              sim_id = 168
            dir_path = tests_output/test_exploration_diagnostics/evaluations/sim0168
objective functions:
                  f1 =  897.35644
                  f2 =  432.31509
varying parameters:
                  x0 =  -41.01475
                  x1 =   12.66837

@delaossa delaossa added the enhancement New feature or request label Jan 30, 2024
@delaossa delaossa requested a review from AngelFP January 30, 2024 10:25
Copy link
Member

@AngelFP AngelFP left a comment

Choose a reason for hiding this comment

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

Thanks for this! Could you implement the changes in the comments and add these two function calls to test_exploration_diagnostics.py?

Comment on lines 57 to 72
self.history_file = os.path.join(path, output_files[-1])
self.params_file = os.path.join(
path, "exploration_parameters.json"
)
elif path.endswith(".npy"):
exploration_dir_path = pathlib.Path(path).parent
output_file = path
params_file = os.path.join(
self.history_file = path
self.params_file = os.path.join(
exploration_dir_path, "exploration_parameters.json"
)
else:
raise RuntimeError(
"The path should either point to a folder or a `.npy` file."
)
exploration = self._create_exploration(
exploration_dir_path, params_file, output_file
exploration_dir_path, self.params_file, self.history_file
Copy link
Member

Choose a reason for hiding this comment

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

Is there a need to store the paths to history_file and params_file in self? They are not used anywhere else.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right, they are not being used anywhere else yet.
Nevertheless, I think that it is important that when one initializes an instance of ExplorationDiagnostics from files, it should be known which are those files.
So the user knows exactly where this data is coming from.

Copy link
Member

@AngelFP AngelFP Feb 2, 2024

Choose a reason for hiding this comment

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

Right, but the path to the data is already in exploration_dir_path. Is there any reason to have the path to the json and npy files? In principle I don't see a use case.

Copy link
Collaborator Author

@delaossa delaossa Feb 2, 2024

Choose a reason for hiding this comment

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

In previous versions there could be more than one history file in the exploration_dir_path.
When this is the case, and just the exploration_dir_path is given, the most recent history file is automatically selected.
Keeping the path to the selected history file seems to me a good practice so it can be known the origin of the data store in ExplorationDiagnostics.
But I see that in newer versions of optimas there is just one history file per exploration_dir_path.
So it should be sufficiently clear which one applies.

self,
top: Optional[int] = 3,
objective: Optional[Union[str, Objective]] = None,
) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
) -> str:
) -> None:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure! thanks


print()

def print_top_evaluations(
Copy link
Member

Choose a reason for hiding this comment

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

To keek it consistent with the other methods, I would change the name to

Suggested change
def print_top_evaluations(
def print_best_evaluations(

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

alright!

sim_path = None
print("%20s = None" % ("dir_path"))

print("objective functions:")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
print("objective functions:")
print("objectives:")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

alright too

@AngelFP AngelFP merged commit 7835331 into optimas-org:main Feb 2, 2024
@delaossa delaossa deleted the feature/print_history branch July 26, 2024 08:08
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.

2 participants