0

I'm following Mosek documentation to retrieve the information of the solver. In particular I want to get the number of constraints by:

Model::t M = new Model("cqo1");

Variable::t x  = M->variable("x", 3, Domain::greaterThan(0.0));
Variable::t y  = M->variable("y", 3, Domain::unbounded());

Variable::t z1 = Var::vstack(y->index(0),  x->slice(0, 2));
Variable::t z2 = Var::vstack(y->slice(1, 3), x->index(2));

auto aval = new_array_ptr<double, 1>({1.0, 1.0, 2.0});
M->constraint("lc", Expr::dot(aval, x), Domain::equalsTo(1.0));

Constraint::t qc1 = M->constraint("qc1", z1, Domain::inQCone());
Constraint::t qc2 = M->constraint("qc2", z2, Domain::inRotatedQCone());

M->objective("obj", ObjectiveSense::Minimize, Expr::sum(y));
int anaProNumCon = M->getSolverIntInfo("anaProNumCon");

However it returns anaProNumCon=0 (should be 3). What could be wrong in the call?

Best

kstn
  • 537
  • 4
  • 14

1 Answers1

1

Information items are only being set after you called M->solve() https://docs.mosek.com/latest/cxxfusion/solver-infitems.html and the ones from the problem analyzer are probably not until you have called the problem analyzer, which is available in the optimizer API only but not Fusion.

Moreover, since your conic constraints are multi-dimensional, the actual number of constraints that would be returned at this point is not 3, but something like 1 (lc) + 3 (qc1 slacks) + 3 (qc2 slacks) = 7 if I am not mistaken.

What I'm trying to say is that this is not a meaningful way of finding out about the problem. The information items always relate to the low-level optimizer task, but you would have to know how the Fusion model is mapped to that low-level task, and that mapping is not part of the API guaranteed by Mosek.

You can do M->writeTask("file.opf") to see how the low-level model looks like. On the other hand if you want to want to know how many Fusion constraints your Fusion model has then you have to keep track of it in your code.

  • Hi Michal Adamaszek, the M->writeTask("file.opf") is an excellent solution to inspect low-level information. Nevertheless the anaProNumCon still shows 0 even when I called M->solve() before it :( – kstn Oct 08 '21 at 12:24
  • 1
    @kstn I think they would only be set if the problem analyzer was invoked. This is some legacy. You can always do ``M->getTask()`` and then go to https://docs.mosek.com/latest/capi/alphabetic-functionalities.html#doc-alpha-functionalities-ref for a list of things you can get from the task. ``MSK_getnumcon``, ``MSK_getnumvar``, ``MSK_getwhateverinfo``. And they will work at any moment when the task is being built if that is important for you. – Michal Adamaszek Oct 08 '21 at 12:36