SCO solution disparity?

86 views
Skip to first unread message

rogerk...@gmail.com

unread,
Apr 4, 2018, 4:51:44 AM4/4/18
to mosek
A user of the R REBayes package has inquired about behavior of Mosek solutions to a toy SCO problem with a square A matrix.
Some further checking revealed that permuting rows of the A matrix yields a different solution even though the objective is simply
a sum of log terms.  I will attach the output files from write_mosek here in the hope that someone can shed some further light
on the nature of this discrepancy and its cause.  Results are based on "MOSEK 8.1.0.33" and Rmosek_8.0.69 on a mac air.
To reproduce the problem compare solutions of the original problem described in the attached files 
with the solution when rows 2 and 3 of the A matrix are interchanged.  In both cases Mosek reports
"Optimal"  but with different solutions and different final objective function values, which seems odd
to say the least.

Roger


P.opf
Psco.opf

Erling D. Andersen

unread,
Apr 4, 2018, 5:07:25 AM4/4/18
to mosek
I am looking into it.

Btw I have bad and good news. The bad news is scopt will be removed in MOSEK version 9.  The good news is that we will add handling of the power cone and exponential cones.
And using those two cones you can model everything you can do with scopt and much more. Solving problems on conic form is more robust and usually faster.


If you want access to a alpha version of v9 let us know.

Erling D. Andersen

unread,
Apr 4, 2018, 5:24:07 AM4/4/18
to mosek
I got

  Problem status  : PRIMAL_AND_DUAL_FEASIBLE
  Solution status : OPTIMAL
  Primal.  obj: 6.3651416892e-01    nrm: 1e+00    Viol.  con: 0e+00    var: 0e+00
  Dual.    obj: 6.3651416913e-01    nrm: 1e+00    Viol.  con: 0e+00    var: 3e-09

and


  Problem status  : PRIMAL_AND_DUAL_FEASIBLE
  Solution status : OPTIMAL
  Primal.  obj: 6.3651416892e-01    nrm: 1e+00    Viol.  con: 0e+00    var: 0e+00
  Dual.    obj: 6.3651416913e-01    nrm: 1e+00    Viol.  con: 0e+00    var: 3e-09

so I could not see any difference running based on your files. So I would start by upgrading MOSEK.
I suggest you post solution summaries as I do above for both runs. 


Den onsdag den 4. april 2018 kl. 10.51.44 UTC+2 skrev rogerk...@gmail.com:

rogerk...@gmail.com

unread,
Apr 4, 2018, 10:55:54 AM4/4/18
to mosek
I've upgraded to > mosek_version()

[1] "MOSEK 8.1.0.47"


but I still get the disparity:  

Interior-point solution summary

  Problem status  : PRIMAL_AND_DUAL_FEASIBLE

  Solution status : OPTIMAL

  Primal.  obj: 6.3651416892e-01    nrm: 1e+00    Viol.  con: 0e+00    var: 0e+00  

  Dual.    obj: 6.3651416913e-01    nrm: 1e+00    Viol.  con: 0e+00    var: 3e-09  

and

Interior-point solution summary

  Problem status  : PRIMAL_AND_DUAL_FEASIBLE

  Solution status : OPTIMAL

  Primal.  obj: 6.7939061968e-01    nrm: 1e+00    Viol.  con: 8e-13    var: 0e+00  

  Dual.    obj: 6.7939061996e-01    nrm: 4e-01    Viol.  con: 0e+00    var: 3e-09   

Erling D. Andersen

unread,
Apr 5, 2018, 2:06:42 AM4/5/18
to mosek
It looks like your are solving two different problems. You get an optimal solution in both cases.
We must be able to reproduce the issue if we should do more about it.

rogerk...@gmail.com

unread,
Apr 5, 2018, 7:11:29 AM4/5/18
to mosek
I'm afraid I misstated the original problem,  I should have specified that the difference between the two problems involved
interchanging COLUMNS 2 and 3 of A,  since the constraints and the objective are symmetric in the coordinates this should yield
the same objective function value at a solution with the second and third components of the solution interchanged.  I hope
that this is more clear now.


On Wednesday, April 4, 2018 at 9:51:44 AM UTC+1, rogerk...@gmail.com wrote:

Erling D. Andersen

unread,
Apr 5, 2018, 8:18:04 AM4/5/18
to mosek
I still cannot reproduce it.  Note mosek contains 

   mskscopt

If you have say

  P.mps
  P.sco

and then you can run

  mskscopt P

The files must have those extension and extension indicates the format i.e. the first file must be an MPS file and not an OPF file.
It could be an issue with the R interface. The above will not test that.

Henrik Alsing Friberg

unread,
Apr 6, 2018, 2:34:02 AM4/6/18
to mosek
I also fail to reproduce it. Here are my steps:


> mosek_version()
[1] "MOSEK 8.1.0.47"



> r <- mosek_read("./P.opf", list(scofile="./P.sco")); print(r)
Open file '/home/hfriberg/incoming/REBayes/P.opf'
Reading started.
Reading terminated. Time: 0.00
$prob
$prob$sense
[1] "minimize"


$prob$c
[1] 0 0 0


$prob$A
3 x 3 sparse Matrix of class "dgTMatrix"
             
[1,] 1 0.5 0.5
[2,] . 1.0 0.5
[3,] . .   0.9


$prob$bc
   
[,1] [,2] [,3]
blc    
0    0    0
buc    
1    1    1


$prob$bx
   
[,1] [,2] [,3]
blx    
0    0    0
bux  
Inf  Inf  Inf


$prob$scopt
$prob$scopt$opro
     
[,1]       [,2]       [,3]      
type
"LOG"      "LOG"      "LOG"    
j    
1          2          3        
f    
-0.3333333 -0.3333333 -0.3333333
g    
1          1          1        
h    
0          0          0        


$prob$scopt$oprc
NULL




$prob$names
$prob$names$task
[1] ""


$prob$names$obj
[1] ""


$prob$names$var
[1] "x0000" "x0001" "x0002"


$prob$names$con
[1] "c0000" "c0001" "c0002"






$response
$response$code
[1] 0


$response$msg
[1] "MSK_RES_OK: No error occurred."




> mosek(r$prob)
Problem
 
Name                   :                
 
Objective sense        : min            
 
Type                   : GECO (general convex optimization problem)
 
Constraints            : 3              
 
Cones                  : 0              
 
Scalar variables       : 3              
 
Matrix variables       : 0              
 
Integer variables      : 0              


Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator - tries                  : 1                 time                   : 0.00          
Lin. dep.  - tries                  : 1                 time                   : 0.00          
Lin. dep.  - number                 : 0              
Presolve terminated. Time: 0.00  
Matrix reordering started.
Local matrix reordering started.
Local matrix reordering terminated.
Matrix reordering terminated.
Problem
 
Name                   :                
 
Objective sense        : min            
 
Type                   : GECO (general convex optimization problem)
 
Constraints            : 3              
 
Cones                  : 0              
 
Scalar variables       : 3              
 
Matrix variables       : 0              
 
Integer variables      : 0              


Optimizer  - threads                : 20            
Optimizer  - solved problem         : the primal    
Optimizer  - Constraints            : 2
Optimizer  - Cones                  : 0
Optimizer  - Scalar variables       : 5                 conic                  : 0              
Optimizer  - Semi-definite variables: 0                 scalarized             : 0              
Factor     - setup time             : 0.00              dense det. time        : 0.00          
Factor     - ML order time          : 0.00              GP order time          : 0.00          
Factor     - nonzeros before factor : 3                 after factor           : 3              
Factor     - dense dim.             : 0                 flops                  : 2.00e+00      
ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME
0   2.7e+00  2.9e+00  0.0e+00  0.00e+00   0.000000000e+00   1.000000000e+00   1.0e+00  0.00
1   2.5e-01  6.5e-01  0.0e+00  1.78e+00   6.652371423e-01   7.961895389e-01   1.7e-01  0.00
2   8.0e-03  6.6e-02  0.0e+00  9.81e-01   6.419840191e-01   6.455812668e-01   1.3e-02  0.00
3   2.2e-04  1.6e-02  0.0e+00  9.98e-01   6.384505804e-01   6.391972427e-01   2.3e-03  0.00
4   2.4e-06  2.1e-03  0.0e+00  9.95e-01   6.367953752e-01   6.368889795e-01   3.0e-04  0.00
5   2.7e-08  3.5e-04  0.0e+00  9.95e-01   6.365584669e-01   6.365733971e-01   4.7e-05  0.00
6   2.7e-10  5.6e-05  0.0e+00  9.99e-01   6.365210357e-01   6.365233372e-01   7.2e-06  0.00
7   2.7e-12  8.8e-06  2.2e-16  1.00e+00   6.365152367e-01   6.365155945e-01   1.1e-06  0.00
8   2.6e-14  1.4e-06  0.0e+00  1.00e+00   6.365143346e-01   6.365143903e-01   1.8e-07  0.00
9   1.3e-16  2.2e-07  0.0e+00  1.00e+00   6.365141942e-01   6.365142029e-01   2.7e-08  0.00
10  1.4e-16  3.4e-08  0.0e+00  1.00e+00   6.365141723e-01   6.365141737e-01   4.3e-09  0.00
11  2.4e-16  5.2e-09  0.0e+00  1.00e+00   6.365141689e-01   6.365141691e-01   6.6e-10  0.00
Optimizer terminated. Time: 0.00  




Interior-point solution summary
 
Problem status  : PRIMAL_AND_DUAL_FEASIBLE
 
Solution status : OPTIMAL
 
Primal.  obj: 6.3651416892e-01    nrm: 1e+00    Viol.  con: 0e+00    var: 0e+00
 
Dual.    obj: 6.3651416913e-01    nrm: 1e+00    Viol.  con: 0e+00    var: 3e-09
Optimizer summary
 
Optimizer                 -                        time: 0.00  
   
Interior-point          - iterations : 11        time: 0.00  
     
Basis identification  -                        time: 0.00  
       
Primal              - iterations : 0         time: 0.00  
       
Dual                - iterations : 0         time: 0.00  
       
Clean primal        - iterations : 0         time: 0.00  
       
Clean dual          - iterations : 0         time: 0.00  
   
Simplex                 -                        time: 0.00  
     
Primal simplex        - iterations : 0         time: 0.00  
     
Dual simplex          - iterations : 0         time: 0.00  
   
Mixed integer           - relaxations: 0         time: 0.00  


$response
$response$code
[1] 0


$response$msg
[1] "MSK_RES_OK: No error occurred."




$sol
$sol$itr
$sol$itr$solsta
[1] "OPTIMAL"


$sol$itr$prosta
[1] "PRIMAL_AND_DUAL_FEASIBLE"


$sol$itr$skc
[1] "UL" "UL" "SB"


$sol$itr$skx
[1] "SB" "SB" "SB"


$sol$itr$xc
[1] 1.0000000 0.9999764 0.6000000


$sol$itr$xx
[1] 0.3333451 0.6666431 0.6666667


$sol$itr$slc
[1] 0 0 0


$sol$itr$suc
[1] 9.999646e-01 3.539270e-05 5.253452e-10


$sol$itr$slx
[1] 6.303960e-10 3.152163e-10 3.152071e-10


$sol$itr$sux
[1] 0 0 0




> r$prob$A <- r$prob$A[,c(1,3,2)]; print(r$prob$A)
3 x 3 sparse Matrix of class "dgTMatrix"
             
[1,] 1 0.5 0.5
[2,] . 0.5 1.0
[3,] . 0.9 .



> mosek(r$prob)
Problem
 
Name                   :                
 
Objective sense        : min            
 
Type                   : GECO (general convex optimization problem)
 
Constraints            : 3              
 
Cones                  : 0              
 
Scalar variables       : 3              
 
Matrix variables       : 0              
 
Integer variables      : 0              


Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator - tries                  : 1                 time                   : 0.00            
Lin. dep.  - tries                  : 1                 time                   : 0.00            
Lin. dep.  - number                 : 0              
Presolve terminated. Time: 0.00    
Matrix reordering started.
Local matrix reordering started.
Local matrix reordering terminated.
Matrix reordering terminated.
Problem
 
Name                   :                
 
Objective sense        : min            
 
Type                   : GECO (general convex optimization problem)
 
Constraints            : 3              
 
Cones                  : 0              
 
Scalar variables       : 3              
 
Matrix variables       : 0              
 
Integer variables      : 0              


Optimizer  - threads                : 20              
Optimizer  - solved problem         : the primal      
Optimizer  - Constraints            : 2
Optimizer  - Cones                  : 0
Optimizer  - Scalar variables       : 5                 conic                  : 0              
Optimizer  - Semi-definite variables: 0                 scalarized             : 0              
Factor     - setup time             : 0.00              dense det. time        : 0.00            
Factor     - ML order time          : 0.00              GP order time          : 0.00            
Factor     - nonzeros before factor : 3                 after factor           : 3              
Factor     - dense dim.             : 0                 flops                  : 2.00e+00        
ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME  
0   2.7e+00  2.9e+00  0.0e+00  0.00e+00   0.000000000e+00   1.000000000e+00   1.0e+00  0.00  
1   2.5e-01  6.5e-01  0.0e+00  1.78e+00   6.652371423e-01   7.961895389e-01   1.7e-01  0.00  
2   8.0e-03  6.6e-02  0.0e+00  9.81e-01   6.419840191e-01   6.455812668e-01   1.3e-02  0.00  
3   2.2e-04  1.6e-02  2.2e-16  9.98e-01   6.384505804e-01   6.391972427e-01   2.3e-03  0.00  
4   2.4e-06  2.1e-03  0.0e+00  9.95e-01   6.367953752e-01   6.368889795e-01   3.0e-04  0.00  
5   2.7e-08  3.5e-04  2.2e-16  9.95e-01   6.365584669e-01   6.365733971e-01   4.7e-05  0.00  
6   2.7e-10  5.6e-05  4.4e-16  9.99e-01   6.365210357e-01   6.365233372e-01   7.2e-06  0.00  
7   2.7e-12  8.8e-06  2.2e-16  1.00e+00   6.365152367e-01   6.365155945e-01   1.1e-06  0.00  
8   2.6e-14  1.4e-06  2.2e-16  1.00e+00   6.365143346e-01   6.365143903e-01   1.8e-07  0.00  
9   1.1e-16  2.2e-07  2.2e-16  1.00e+00   6.365141942e-01   6.365142029e-01   2.7e-08  0.00  
10  1.3e-16  3.4e-08  2.2e-16  1.00e+00   6.365141723e-01   6.365141737e-01   4.3e-09  0.00  
11  2.5e-16  5.2e-09  2.2e-16  1.00e+00   6.365141689e-01   6.365141691e-01   6.6e-10  0.00  
Optimizer terminated. Time: 0.00    




Interior-point solution summary
 
Problem status  : PRIMAL_AND_DUAL_FEASIBLE
 
Solution status : OPTIMAL
 
Primal.  obj: 6.3651416892e-01    nrm: 1e+00    Viol.  con: 0e+00    var: 0e+00  
 
Dual.    obj: 6.3651416913e-01    nrm: 1e+00    Viol.  con: 0e+00    var: 3e-09  
Optimizer summary
 
Optimizer                 -                        time: 0.00    
   
Interior-point          - iterations : 11        time: 0.00    
     
Basis identification  -                        time: 0.00    
       
Primal              - iterations : 0         time: 0.00    
       
Dual                - iterations : 0         time: 0.00    
       
Clean primal        - iterations : 0         time: 0.00    
       
Clean dual          - iterations : 0         time: 0.00    
   
Simplex                 -                        time: 0.00    
     
Primal simplex        - iterations : 0         time: 0.00    
     
Dual simplex          - iterations : 0         time: 0.00    
   
Mixed integer           - relaxations: 0         time: 0.00    


$response
$response$code
[1] 0


$response$msg
[1] "MSK_RES_OK: No error occurred."




$sol
$sol$itr
$sol$itr$solsta
[1] "OPTIMAL"


$sol$itr$prosta
[1] "PRIMAL_AND_DUAL_FEASIBLE"


$sol$itr$skc
[1] "UL" "UL" "SB"


$sol$itr$skx
[1] "SB" "SB" "SB"


$sol$itr$xc
[1] 1.0000000 0.9999764 0.6000000


$sol$itr$xx
[1] 0.3333451 0.6666667 0.6666431


$sol$itr$slc
[1] 0 0 0


$sol$itr$suc
[1] 9.999646e-01 3.539270e-05 5.253452e-10


$sol$itr$slx
[1] 6.303960e-10 3.152071e-10 3.152163e-10


$sol$itr$sux
[1] 0 0 0


rogerk...@gmail.com

unread,
Apr 6, 2018, 4:30:27 AM4/6/18
to mosek
My profound apologies,  this was all eventually traced back to a rather obscure "feature"  of the sparse matrix R package "Matrix".
My original code used A <- Matrix(A, sparse = TRUE) which produced a matrix that failed to recognize the symmetry of the original A.
Whereas A <- Matrix(A, "dgCMatrix") produces a matrix of class "dsyMatrix"  and this when passed to Rmosek yields consistent
results.  Upshot:  [r]mosek is fine,  the problems all lay with my faulty understanding of Matrix classes.  Thanks for your patience!
I look forward (with a little trepidation) to v9!


On Wednesday, April 4, 2018 at 9:51:44 AM UTC+1, rogerk...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages