SolveJob¶
A SolveJob represents a job for solving an optimization problem using LunaSolve. For more details, visit the API Reference.
Get Status of a SolveJob¶
You can retrieve the status of a SolveJob with:
By specifying the status_source with remote you enforce retrieving the status from the LunaPlatform.
The default behavior is cached and uses the status retrieved from the cached status.
Get the Results of a SolveJob¶
Retrieve the results of the SolveJob from Luna with:
This will wait until the result is available. You can specify a timeout.
Refer to Solution how to evaluate the result object.
Cancel a SolveJob¶
You can cancel a SolveJob as long as it hasn't started yet. To cancel a SolveJob use:
Deleting a SolveJob¶
If you no longer need the SolveJob including its results, then you can delete it with:
Hint
Delete finished SolveJobs. Use the cancel method to cancel the execution of the SolveJob.
API Reference¶
SolveJob ¶
Bases: BaseModel
A model to represent a job for solving model problems.
is_cancellation_requested class-attribute instance-attribute ¶
cancel ¶
Cancel a solve job.
This method cancels an already initiated solve job using the provided client or a default one if no client is specified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client | Optional[ILunaSolve] | The client instance used to perform the cancel operation. If None, the client is obtained via the ClientFactory. | None |
Returns:
| Type | Description |
|---|---|
None | |
delete ¶
Delete a job using the specified or default client.
This method deletes this job and solution. A client can optionally be provided otherwise, a default client is obtained through the factory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client | Optional[ILunaSolve] | The client to be used for job deletion. If not provided, a default client is retrieved using | None |
get_status ¶
get_status(
client: ILunaSolve | None = None,
status_source: Literal["cached", "remote"] = "cached",
) -> StatusEnum
Retrieve the current status of the solve job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_source | Literal['cached', 'remote'] | If "cached", the status is retrieved from the cached status. If "remote", the status is retrieved from the remote service. | 'cached' |
client | Optional[ILunaSolve] | The client to be used. If not provided, a new client is created using | None |
Returns:
| Type | Description |
|---|---|
StatusEnum | The current status of the solve job, represented as a value from the |
result ¶
result(
client: ILunaSolve | None = None,
sleep_time_max: float = 60.0,
sleep_time_increment: float = 5.0,
sleep_time_initial: float = 5.0,
call_style: CallStyle = ACTIVE_WAITING,
) -> Solution | None
Get the result of the solve job.
This function uses the provided client or creates a new one to retrieve and the result of this solve job. Depending on the call style, it can actively wait for the result or return immediately.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client | Optional[ILunaSolve] | The client to be used. If not provided, a new client is created using ClientFactory. | None |
sleep_time_max | float | Maximum sleep time in seconds between consecutive active waiting checks. | 60.0 |
sleep_time_increment | float | Increment value for the sleep time between checks during active waiting. | 5.0 |
sleep_time_initial | float | Initial sleep time in seconds for the active waiting process. | 5.0 |
call_style | CallStyle | Determines if this function will actively wait for the result or return immediately. | ACTIVE_WAITING |
Returns:
| Type | Description |
|---|---|
Optional[Solution] | The result of the solve job or None if not available. |
Raises:
| Type | Description |
|---|---|
Any exceptions raised by the use case's solve job call will propagate. | |