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

Option to save .optimize results to a .txt or .json file #1433

Open
dpanici opened this issue Dec 6, 2024 · 2 comments
Open

Option to save .optimize results to a .txt or .json file #1433

dpanici opened this issue Dec 6, 2024 · 2 comments
Assignees
Labels
enhancement General label for enhancement. Please also tag with "Speed", "Interface", "Functionality", etc P2 Medium Priority, not urgent but should be on the near-term agend

Comments

@dpanici
Copy link
Collaborator

dpanici commented Dec 6, 2024

It could be useful to save the optimization results in a friendly format so that it can be read with existing packages, json is one such option I think. We could add a save_json=False flag to optimize that will save a json file with the name of each objective and their min/max/avg values (both normalized and not), so that one need not scrape the print output in order to get that info.

@dpanici dpanici added enhancement General label for enhancement. Please also tag with "Speed", "Interface", "Functionality", etc P2 Medium Priority, not urgent but should be on the near-term agend labels Dec 6, 2024
@dpanici dpanici self-assigned this Dec 6, 2024
@dpanici
Copy link
Collaborator Author

dpanici commented Dec 6, 2024

Should just be modifying ObjectiveFunction.print_value to return the string (if just writing to a .txt file) and/or also having it return a dict with the data, which should be able to be saved as a json, something like adding the following to the print part of the Optimizer.optimize method

string, data = obj.print_value(obj.x(state), obj.x(state0))

with open(json_save_path,"w+") as f:
    json.dump(data,f)

@dpanici
Copy link
Collaborator Author

dpanici commented Dec 9, 2024

add extra info for the initial/final obj values to results output from .optimize as well to avoid the extra print_value call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement General label for enhancement. Please also tag with "Speed", "Interface", "Functionality", etc P2 Medium Priority, not urgent but should be on the near-term agend
Projects
None yet
Development

No branches or pull requests

1 participant