The documentation for semidefinite programming
doc.sagemath.org/html/en/reference/numerical/sage/numerical/sdp.html
indicates that there is an available solver for an SDP problem over QQ (rather than RDF):
For representing an SDP with exact data, there is another backend
I tried to build a basic example of this functionality by combining two of the sample code blocks on that page, but I get a NotImplementedError
in SageMathCell. I have dumped my code below.
Could anyone confirm/deny that the QQ functionality is supported? If it is supported, perhaps I am missing an import or wrongly specifying my solver -- perhaps someone could debug this for me?
from sage.numerical.backends.matrix_sdp_backend import MatrixSDPBackend
p = SemidefiniteProgram(solver=MatrixSDPBackend, base_ring=QQ)
x = p.new_variable()
p.set_objective(x[1] - x[0])
a1 = matrix([[1, 2], [2, 3]])
a2 = matrix([[3, 4], [4, 5]])
a3 = matrix([[5, 6], [6, 7]])
b1 = matrix([[1, 1], [1, 1]])
b2 = matrix([[2, 2], [2, 2]])
b3 = matrix([[3, 3], [3, 3]])
c1 = matrix([[1, 0],[0,0]],sparse=True)
c2 = matrix([[0, 0],[0,1]],sparse=True)
p.add_constraint(a1*x[0] + a2*x[1] <= a3)
p.add_constraint(b1*x[0] + b2*x[1] <= b3)
p.add_constraint(c1*x[0] + c2*x[1] >= matrix.zero(2,2,sparse=True))
p.solver_parameter("show_progress", True)
opt = p.solve()
print('Objective Value: {}'.format(N(opt,3)))
[N(x, 3) for x in sorted(p.get_values(x).values())]
p.show()