This article explains how to download additional solve metadata for a completed solve using rosepy. You can also retrieve solve metadata directly via the API, available for any language. For that, see the API specific help article.
Prerequisites
- Your API key and secret must be specified in the environment variables
ROSEPY_API_KEY_IDandROSEPY_API_KEY_SECRET. If you need to create an API key, the steps for doing that can be found in the article on Creating an API key and secret. - Having a solve ID to pass in for the
solve_idvariable. You can get this from:- If using the API to submit your solves, the response to the
/solveendpoint is a list of solve ID(s) - If looking through the web UI, the solve ID can be found in the URL where it says
id=, for example this solve ID is 1234./solve?id=1234
- If using the API to submit your solves, the response to the
Sample Code Snippet
Running the above below returns a Python dictionary with solve metadata such as solve time, number of variables, and solver status. The actual solution values are not included, use the web interface or the API /solution endpoint to access the solution. If the solve ID is invalid or not yet complete, get_solve_results will raise an exception and return None.
from rosepy.pyomo.pyomo_interface import Connection
from rosepy.solve_activity import SolveActivity
solve_id = "<populate your solve ID here>"
connection = Connection()
connection.connect()
solve_activity = SolveActivity(connection)
solve = solve_activity._get_solve_results(solve_id=solve_id)
if solve is not None:
solve_dict = solve.model_dump()
connection.disconnect()
Comments
0 comments
Please sign in to leave a comment.