Constraint Violation

220 views
Skip to first unread message

Anton Hinneck

unread,
Mar 24, 2021, 10:00:07 AM3/24/21
to mosek
Good afternoon,

I tried to find an answer to this question, but was not successful. I am solving a SOCP and need the resulting variable values x to solve a subsequent model.

In the model I have: x >= 0 (1) and sum(x) == 1 (2)


As can be seen, the variable values are negative after optimization (due to tolerances I suppose). This would not be an issue, if the same tolerances would apply during presolve - but they don't. If I solve the model a second time fixing variable values, the instance is classified infeasible (I have this issue for both types of constraints).

Which flags have to be adjusted to tackle this issue?

Sincerely,

Anton Hinneck

---
PhD Student
Skoltech
Energy Systems and Technologies


Erling D. Andersen

unread,
Mar 24, 2021, 10:05:24 AM3/24/21
to mosek
Sorry, but you write

   As can be seen,

but I do not really see anything relevant. All I can conclude is that you do not think Mosek is not solving the your model accurately enough.

If I should help, then

* Tells me which interface you are using.
* Include the log output from Mosek. In particularly the solution summary is very valuable.

Anton Hinneck

unread,
Mar 24, 2021, 10:57:01 AM3/24/21
to mo...@googlegroups.com
Thank you for the fast response.
I wanted to insert this screenshot inline (didn't work):

Screenshot from 2021-03-24 16.15.06.png

I am using Julia 1.5.3, Mosek.jl 1.1.3 and Mosek 9.2.40.



--
You received this message because you are subscribed to a topic in the Google Groups "mosek" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mosek/gUJteBtxPMo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mosek+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mosek/096c232c-1728-41c9-a5b5-005a4e5da312n%40googlegroups.com.

Erling D. Andersen

unread,
Mar 24, 2021, 11:15:42 AM3/24/21
to mosek
I assume that is variable values and they are supposed to be nonnegative.

Given that it looks like a violation that is within tolerances. Whether they are or not depends
on the actual model e.g. scaling and general conditioning.

As long as you use an optimizer such as Mosek that employs finite precision floating numbers on a non trivial
model you have to accept minor violations. This is what I learned in my numerical analysis class at university
quite some years ago holds for linear equations and hence by extension also for optimization problems.

To summarize unless you are lucky then changing a flag or two will not solve your problem. How to solve your issue
is hard for me to specify given the limited knowledge I have about what you want to do.

Seeing the complete solution summary i.e.


would be helpful to give a more firm judgement.

PS. You cannot apply the same tolerances in presolve and in the optimizer. This is way more complicated than one naively should think.

Anton Hinneck

unread,
Mar 25, 2021, 3:16:43 AM3/25/21
to mo...@googlegroups.com
P.S. Full Console Log:

Problem
  Name                   :                
  Objective sense        : min            
  Type                   : CONIC (conic optimization problem)
  Constraints            : 9404            
  Cones                  : 58              
  Scalar variables       : 4261            
  Matrix variables       : 0              
  Integer variables      : 0              

Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 78
Eliminator terminated.
Eliminator - tries                  : 1                 time                   : 0.00            
Lin. dep.  - tries                  : 1                 time                   : 0.00            
Lin. dep.  - number                 : 0              
Presolve terminated. Time: 0.01    
Problem
  Name                   :                
  Objective sense        : min            
  Type                   : CONIC (conic optimization problem)
  Constraints            : 9404            
  Cones                  : 58              
  Scalar variables       : 4261            
  Matrix variables       : 0              
  Integer variables      : 0              

Optimizer  - threads                : 4              
Optimizer  - solved problem         : the dual        
Optimizer  - Constraints            : 2522
Optimizer  - Cones                  : 59
Optimizer  - Scalar variables       : 10207             conic                  : 1528            
Optimizer  - Semi-definite variables: 0                 scalarized             : 0              
Factor     - setup time             : 0.03              dense det. time        : 0.01            
Factor     - ML order time          : 0.01              GP order time          : 0.00            
Factor     - nonzeros before factor : 2.28e+04          after factor           : 4.04e+04        
Factor     - dense dim.             : 29                flops                  : 1.19e+06        
ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME  
0   1.3e+03  2.5e+02  5.2e+00  0.00e+00   2.828427125e+00   -1.414213562e+00  1.0e+00  0.04  
1   1.2e+03  2.4e+02  5.1e+00  -9.63e-01  -2.421715270e+03  -2.425898623e+03  9.7e-01  0.05  
2   1.0e+03  1.9e+02  4.5e+00  -9.29e-01  -5.282945399e+03  -5.286825407e+03  7.8e-01  0.05  
3   6.7e+02  1.3e+02  3.5e+00  -8.73e-01  -4.987719038e+03  -4.990942956e+03  5.2e-01  0.05  
4   6.1e+02  1.2e+02  3.3e+00  -7.54e-01  -4.370373166e+03  -4.373446956e+03  4.8e-01  0.06  
5   5.8e+02  1.1e+02  3.1e+00  -7.33e-01  -3.596602468e+03  -3.599593766e+03  4.5e-01  0.06  
6   4.9e+02  9.6e+01  2.8e+00  -7.24e-01  1.252384547e+03   1.249685100e+03   3.8e-01  0.06  
7   3.0e+02  5.9e+01  1.9e+00  -6.57e-01  1.587540806e+04   1.587368871e+04   2.4e-01  0.07  
8   1.8e+02  3.5e+01  1.3e+00  -4.90e-01  3.105162457e+04   3.105091156e+04   1.4e-01  0.07  
9   1.1e+02  2.2e+01  7.8e-01  -2.87e-01  4.545849177e+04   4.545850529e+04   8.7e-02  0.07  
10  8.1e+01  1.6e+01  6.3e-01  -2.91e-01  5.274245533e+04   5.274318521e+04   6.3e-02  0.08  
11  3.6e+01  7.1e+00  2.7e-01  -9.21e-02  7.508569390e+04   7.508704648e+04   2.8e-02  0.08  
12  2.5e+01  4.9e+00  1.9e-01  2.05e-02   8.155343891e+04   8.155508823e+04   2.0e-02  0.08  
13  2.0e+01  4.0e+00  1.5e-01  3.80e-02   8.543455594e+04   8.543632374e+04   1.6e-02  0.09  
14  1.7e+01  3.3e+00  1.2e-01  7.23e-02   8.853403179e+04   8.853585143e+04   1.3e-02  0.09  
15  6.4e+00  1.2e+00  4.2e-02  1.17e-01   1.063111242e+05   1.063129822e+05   5.0e-03  0.09  
16  3.7e+00  7.2e-01  2.1e-02  4.25e-01   1.144881976e+05   1.144896235e+05   2.9e-03  0.10  
17  2.5e+00  4.9e-01  1.2e-02  5.80e-01   1.191015591e+05   1.191026889e+05   2.0e-03  0.10  
18  1.7e+00  3.4e-01  7.6e-03  6.64e-01   1.225213713e+05   1.225222797e+05   1.3e-03  0.10  
19  1.6e+00  3.2e-01  7.1e-03  6.57e-01   1.229611998e+05   1.229620863e+05   1.3e-03  0.11  
20  1.3e+00  2.5e-01  5.2e-03  6.55e-01   1.249971852e+05   1.249979934e+05   9.8e-04  0.11  
21  8.9e-01  1.7e-01  3.2e-03  7.31e-01   1.273865172e+05   1.273871552e+05   7.0e-04  0.12  
22  6.8e-01  1.3e-01  2.2e-03  8.01e-01   1.288601286e+05   1.288606496e+05   5.3e-04  0.12  
23  6.4e-01  1.3e-01  2.2e-03  6.74e-01   1.286442025e+05   1.286448016e+05   5.0e-04  0.12  
24  6.1e-01  1.2e-01  2.0e-03  5.84e-01   1.290234821e+05   1.290240276e+05   4.8e-04  0.12  
25  5.0e-01  9.7e-02  1.6e-03  5.88e-01   1.296173929e+05   1.296179392e+05   3.9e-04  0.13  
26  4.0e-01  7.8e-02  1.2e-03  5.48e-01   1.305907946e+05   1.305912437e+05   3.1e-04  0.13  
27  3.3e-01  6.5e-02  9.3e-04  4.50e-01   1.312908284e+05   1.312912157e+05   2.6e-04  0.13  
28  2.3e-01  4.6e-02  5.7e-04  7.12e-01   1.323399765e+05   1.323402790e+05   1.8e-04  0.14  
29  1.9e-01  3.8e-02  4.4e-04  7.27e-01   1.328221037e+05   1.328223675e+05   1.5e-04  0.14  
30  8.6e-02  1.7e-02  1.4e-04  8.45e-01   1.342799077e+05   1.342800411e+05   6.7e-05  0.14  
31  4.8e-02  9.5e-03  6.1e-05  9.49e-01   1.348122632e+05   1.348123450e+05   3.8e-05  0.15  
32  1.5e-02  3.0e-03  1.1e-05  9.75e-01   1.353150915e+05   1.353151187e+05   1.2e-05  0.15  
33  5.1e-03  1.0e-03  2.2e-06  9.82e-01   1.354658709e+05   1.354658812e+05   4.0e-06  0.15  
34  1.7e-03  3.4e-04  4.5e-07  9.91e-01   1.355194682e+05   1.355194718e+05   1.4e-06  0.16  
35  7.5e-04  1.5e-04  1.3e-07  1.00e+00   1.355352744e+05   1.355352760e+05   5.9e-07  0.16  
36  2.0e-04  4.0e-05  1.9e-08  1.00e+00   1.355443805e+05   1.355443810e+05   1.6e-07  0.16  
37  5.4e-05  1.1e-05  2.7e-09  1.00e+00   1.355469397e+05   1.355469398e+05   4.3e-08  0.17  
38  1.6e-05  3.0e-06  5.5e-10  1.00e+00   1.355476114e+05   1.355476115e+05   1.2e-08  0.17  
39  1.2e-05  2.3e-06  3.8e-10  1.00e+00   1.355476817e+05   1.355476818e+05   9.4e-09  0.18  
40  9.4e-06  1.8e-06  1.6e-10  1.00e+00   1.355477317e+05   1.355477318e+05   7.5e-09  0.18  
41  8.6e-06  1.7e-06  3.4e-10  1.00e+00   1.355477755e+05   1.355477755e+05   7.1e-09  0.19  
42  8.6e-06  1.7e-06  3.4e-10  1.00e+00   1.355477755e+05   1.355477755e+05   7.1e-09  0.19  
43  8.6e-06  1.7e-06  3.4e-10  1.00e+00   1.355477755e+05   1.355477755e+05   7.1e-09  0.20  
Optimizer terminated. Time: 0.22

For this specific model, Mosek classifies its own solution infeasible.

Anton Hinneck

unread,
Mar 25, 2021, 3:16:47 AM3/25/21
to mo...@googlegroups.com
Thank you, I am currently circumventing these numerical issues on a higher level (during constraint definition) by
- not using equalities to fix variable values but rather narrow intervals,
- adjusting numbers manually (setting negative values to 0) to make sure my constraints are not violated
before constructing a second model using solver output.

This workes for me but is quite tedious, as it is not always obvious which constraints are violated.

Thanks, I will give the docs another thorough read.

Best regards,

Anton Hinneck

Erling D. Andersen

unread,
Mar 25, 2021, 3:20:20 AM3/25/21
to mosek
The logout seems to indicate Mosek finds a feasible solution.

Since the Mosek solution summary is not shown I cannot conclude anything.

If you used the Mosek optimizer API you could call a functions to get the solution summary shown.
I do not know Julia well enough to know if that is possible.

Erling D. Andersen

unread,
Mar 25, 2021, 3:29:51 AM3/25/21
to mosek
Just a note. 

Having ranged variables/constraints where the lower and upper bound are close makes the problem hard in theory i.e.

0<= x <=1.0e-8

is not such a good idea. But might be the best solution to your problem.

Anton Hinneck

unread,
Mar 26, 2021, 7:49:59 AM3/26/21
to mosek
Thanks again. Julia just wraps the native C API Mosek ships with.

solutionsummary(...) yields:

Interior-point solution summary
  Problem status  : PRIMAL_AND_DUAL_FEASIBLE
  Solution status : OPTIMAL
  Primal.  obj: 1.3154925077e+05    nrm: 1e+05    Viol.  con: 1e-05    var: 1e-06    cones: 2e-09  
  Dual.    obj: 1.3154925081e+05    nrm: 1e+05    Viol.  con: 1e-11    var: 8e-09    cones: 0e+00

You are right, I am not going to be able to avoid these issues fully.
Even though negative, all values are within tolerance.
I will try what you proposed and adjust nonnegativity for the optimizer tolerance.

Is there a way to disable feasibility check on the model before starting the optimizer?

Anton Hinneck

unread,
Mar 26, 2021, 7:50:02 AM3/26/21
to mosek
P.S. Redefining non-negativity constraints  such that "lb + constraint_violation_tolerance <= x" might also ensure that a solution vector satisfies a problem's constraints. This could be applied to any constraint for that matter.

Erling D. Andersen schrieb am Donnerstag, 25. März 2021 um 10:29:51 UTC+3:

Erling D. Andersen

unread,
Mar 26, 2021, 7:53:42 AM3/26/21
to mosek
The solution summary shows that you get a decent solution.

You can try disabling presolve but I strongly recommend against that.
Since presolve should be as integral part that in general improves the numerics
of the model.




Reply all
Reply to author
Forward
0 new messages