Skip to content

Latest commit

 

History

History
66 lines (48 loc) · 1.39 KB

optimization-job-reference.md

File metadata and controls

66 lines (48 loc) · 1.39 KB
author description ms.author ms.date ms.service ms.subservice ms.topic title uid
george-moussa
Reference for azure.quantum.optimization.Job
georgenm
02/01/2021
azure-quantum
optimization
reference
Quantum optimization job
microsoft.quantum.optimization.job-reference

Quantum optimization Job

from azure.quantum.optimization import Job

Job.get_results

Retrieves the job result (that is, the computed solution and cost). If the job has not yet finished, blocks until it has.

results = job.get_results()
print(results)

> {'version': '1.0', 'configuration': {'1': 1, '0': 1, '2': -1, '3': 1}, 'cost': -23.0}

Job.refresh

Refreshes the job's details by querying the workspace.

job = workspace.get_job(jobId)
job.refresh()
print(job.id)

> 5d2f9cd70f55f149e3ed3aef

Job.has_completed

Returns a boolean value indicating whether the job has finished (for example, the job is in a final state).

job = workspace.get_job(jobId)
job.refresh()
print(job.has_completed())

> False

Job.wait_until_completed

Keeps refreshing the job's details until it reaches a final state. For more information on job states, see Azure Quantum Overview.

job = workspace.get_job(jobId)
job.wait_until_completed()
print(job.has_completed())

> True