import os
assert "DEEPNOTE_PROJECT_ID" in os.environ, "This tutorial is meant to be run on Deepnote"import os
import os.path

import ipywidgets as widgets  # Our use requires ipywidgets >= 7.5.0
from IPython.display import display

if "MOSEKLM_LICENSE_FILE" not in os.environ:
    # If a mosek.lic file has already been uploaded, then simply use it here.
    if os.path.exists('/tmp/mosek.lic'):
        os.environ["MOSEKLM_LICENSE_FILE"] = "/tmp/mosek.lic"
    else:
        uploader = widgets.FileUpload(accept='.lic', multiple=False)
        display(uploader)if "MOSEKLM_LICENSE_FILE" not in os.environ:
    assert len(uploader.value.values()) > 0, "Please upload a license file using the Upload widget above."
    with open('/tmp/mosek.lic', 'wb') as output_file:
        output_file.write(list(uploader.value.values())[-1]['content']) 
    os.environ["MOSEKLM_LICENSE_FILE"] = "/tmp/mosek.lic"from pydrake.solvers import MosekSolver

print(MosekSolver().enabled())from pydrake.solvers import MathematicalProgram, MosekSolver

prog = MathematicalProgram()
S = prog.NewSymmetricContinuousVariables(2, "S")

# S ≽ 0.
prog.AddPositiveSemidefiniteConstraint(S)

# S(1, 0) = 1
prog.AddBoundingBoxConstraint(1, 1, S[1, 0])

# min Trace(S)
prog.AddLinearCost(S[0,0] + S[1,1])

mosek = MosekSolver()
result = mosek.Solve(prog)
assert result.is_success()

print(result.GetSolution(S))if os.path.exists('/tmp/mosek.lic'):
    os.remove('/tmp/mosek.lic')