Методы для получения количества переменных и ограничений модели, похоже, не работают.
Вот код:
GRBVar x = model.addVar(0.0, GRB.INFINITY, 0.0, GRB.CONTINUOUS, "x");
GRBLinExpr expr = new GRBLinExpr();
expr.addTerm(1.0, x);
GRBConstr c0 = model.addConstr(expr, GRB.LESS_EQUAL, 4.0, "c0");
System.out.println("Number of variables: " + model.get(IntAttr.NumVars));
System.out.println("Number of constraints: " + model.get(IntAttr.NumConstrs));
System.out.println("UB = " + c0.get(DoubleAttr.RHS));
Вывод:
Number of variables: 0
Number of constraints: 0
Error code: 10006. Error at GRBConstr.get