ERGO-Code / HiGHS

Linear optimization software
MIT License
976 stars 180 forks source link

LP failing with parallel=on (EKK parallel dual simplex) #780

Closed NPC closed 2 years ago

NPC commented 2 years ago

Hello,

I'm using Windows binaries from #746, but also calling v1.2.1 from my C# code. If running highs.exe with my simple MPS file, with parallel=on it fails silently without finding a solution:

highs.exe --parallel on my.mps
Running HiGHS 1.2.0 [date: , git hash: ]
Copyright (c) 2022 ERGO-Code under MIT licence terms
LP   mySno has 3 rows; 4 cols; 6 nonzeros
Presolving model
1 rows, 2 cols, 2 nonzeros
1 rows, 2 cols, 2 nonzeros                                                                                                                                      
Presolve : Reductions: rows 1(-2); columns 2(-2); elements 2(-4)                                                                                                
Solving the presolved LP                                                                                                                                        
Using EKK parallel dual simplex solver - PAMI with concurrency of 8                                                                                               Iteration        Objective     Infeasibilities num(sum)                                                                                                                 
0     0.0000000000e+00 Ph1: 0(0) 0s

Without parallel I get the following output, a solution is found:

highs.exe --parallel off my.mps                                               
Running HiGHS 1.2.0 [date: , git hash: ]                                                                                                                        
Copyright (c) 2022 ERGO-Code under MIT licence terms                                                                                                            
LP   mySno has 3 rows; 4 cols; 6 nonzeros                                                                                                                       
Presolving model                                                                                                                                                
1 rows, 2 cols, 2 nonzeros                                                                                                                                      
1 rows, 2 cols, 2 nonzeros
Presolve : Reductions: rows 1(-2); columns 2(-2); elements 2(-4)                                                                                                
Solving the presolved LP                                                                                                                                        
Using EKK dual simplex solver - serial                                                                                                                            
Iteration        Objective     Infeasibilities num(sum)                                                                                                                 
0     0.0000000000e+00 Ph1: 0(0) 0s                                                                                                                             
1    -1.4952000000e+02 Pr: 0(0) 0s                                                                                                                    
Solving the original LP from the solution after postsolve                                                                                                       
Model   status      : Optimal                                                                                                                                   
Simplex   iterations: 1                                                                                                                                         
Objective value     : -1.4952000000e+02                                                                                                                         
HiGHS run time      :          0.02

When called from C# in debug mode, it fails in run() method of highs_csharp_interfaces.cs, which calls HighsLpSolver.Highs_run(this.highs). Here's the exception text (not too helpful):

System.AccessViolationException
  HResult=0x80004003
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

I don't have this issue with pre-built mingw win binaries for v1.1.1.

The MPS input:

NAME          Sno
ROWS
 N  __OBJ___
 L  R3
 E  R2
 E  R4
COLUMNS
    C1        __OBJ___  -.8900000000   R2        1.0000000000
    C1        R3        1.0000000000
    C2        __OBJ___  2.2200000000   R2        1.0000000000
    C3        __OBJ___  -.8900000000   R4        1.0000000000
    C3        R3        1.0000000000
    C4        __OBJ___  .00000000000   R4        1.0000000000
RHS
    RHS1      R2        100.00000000   R4        100.00000000
    RHS1      R3        168.00000000
BOUNDS
 UP BND1      C1        100.00000000
 UP BND1      C2        100.00000000
 UP BND1      C3        100.00000000
 UP BND1      C4        100.00000000
ENDATA
jajhall commented 2 years ago

Thanks. I'll look at this, but I fear that we may have to disable parallel simplex, as it's hard to maintain and, as features are added to the serial solver, the chance of getting better performance with the parallel code reduces.

NPC commented 2 years ago

@jajhall thanks for investigating this. It could still be a build issue, as I understand. I don't know enough about these algorithms to tell if dropping parallel is a good call or not (you're the pro!), but it did run faster in my tests of v1.1.1. Plus, it is always a pleasure to see more cores busy :)

jajhall commented 2 years ago

Fixed by #924