Open NPC opened 11 months ago
I've downloaded your example, and it solves in no time from the command line - which is what you would also expect, given your comments. My only observation was that on a none-too-new PC, the run time was 0.01s, rather than your 0.45s
Looking at the output for your "rogue" run, I observe that the 32 iterations of parallel dual simplex required to solve the presolved LP take 89.99s, but the 6 iterations of serial primal simplex required to solve the original LP from the optimal solution of the presolved LP take "0.00" seconds. This makes me think that there's an issue with multithreading.
Running the dual simplex solver in parallel - particularly for a problem of this size - is of questionable value so try omitting parallel=on
option (however you set it).
Of course the "debug" run also uses parallel dual simplex. When you say "debug", I guess you're compiling with the debugging flag (by setting cmake -DCMAKE_BUILD_TUPE=debug
) otherwise I don't see the difference in the "debug" run
Unfortunately, if this rogue behaviour is due to calling from C# then we can't help. The HiGHS C# API was written by someone else, and I don't even know how to run HiGHS via C#
@jajhall thank you for your response and investigation. Turning parallel off doesn't help. Reverting to 1.5.3 doesn't help either. I agree that it looks like an environment issue, but I can't figure out what.
By debug I mean running from our webapplication vs running from C# code in the Visual Studio (so it's the same HiGHS DLL, not a different “debug” version). Which shouldn't have much difference either (I compare the .mps we generate etc), but obviously something is different.
Thanks again for trying to help, this is something on my side, and I don't even know how to keep looking. I doubt you'll be able to help further at this point, so you can close the issue.
Thanks. Sorry I can't help, but it does sound like something at your end.
@jajhall hello again, I'm not sure if this qualifies as a new issue, plus I'm very aware that this is likely something with how the library is called and multithreading, but I hope for some advice. I've ran accross another example where HiGHS exe solves a problem in seconds, but calling from C# seems to take forever (I simply stopped waiting).
Yet, disabling parallel works, and I get a quick solution. This is something I'll have to do for now, even though for our larger problems parallel was showing a significant improvement, and was one of the reasons we went with HiGHS.
I'm not uploading .mps yet (should I?), but perhaps you'll be able to recommend what to investigate in this situation. Here's the log for the “endless” case:
Running HiGHS 1.6.0: Copyright (c) 2023 HiGHS under MIT licence terms
Presolving model
145 rows, 107305 cols, 745933 nonzeros
145 rows, 107214 cols, 745842 nonzeros
Presolve : Reductions: rows 145(-117); columns 107214(-99); elements 745842(-216)
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
321 -9.8922096347e+06 Pr: 0(0); Du: 0(9.7114e-09) 2s
321 -9.8922096347e+06 Pr: 0(0); Du: 0(9.7114e-09) 2s
Using EKK parallel dual simplex solver - PAMI with concurrency of 8
Iteration Objective Infeasibilities num(sum)
321 -9.8922096347e+06 Pr: 11(0.00263214); Du: 0(4.58177e-11) 2s
WARNING: Increasing Markowitz threshold to 0.5
321 -9.8922096347e+06 Pr: 11(0.00263214); Du: 0(4.58191e-11) 7s
321 -9.8922096347e+06 Pr: 11(0.00263214); Du: 0(4.58191e-11) 12s
...
…Then 321 repeats for as long as I waited (over an hour). Does this repeating iteration number mean something? Is the warning significant? And why is the “Using EKK parallel dual simplex solver - PAMI with concurrency of 8” stated twice in the log?
Here's the successful log, with parallel off, quite a contrast (although “Using EKK dual simplex solver - serial” line is still repeated):
Running HiGHS 1.6.0: Copyright (c) 2023 HiGHS under MIT licence terms
Presolving model
145 rows, 107305 cols, 745933 nonzeros
145 rows, 107214 cols, 745842 nonzeros
Presolve : Reductions: rows 145(-117); columns 107214(-99); elements 745842(-216)
Solving the presolved LP
Using EKK dual simplex solver - serial
Iteration Objective Infeasibilities num(sum)
0 0.0000000000e+00 Ph1: 0(0) 0s
350 -9.8922096347e+06 Pr: 0(0); Du: 0(7.6456e-09) 2s
350 -9.8922096347e+06 Pr: 0(0); Du: 0(7.6456e-09) 2s
Using EKK dual simplex solver - serial
Iteration Objective Infeasibilities num(sum)
350 -9.8922096347e+06 Pr: 9(0.0021); Du: 0(3.96555e-11) 2s
390 -9.8922096347e+06 Pr: 0(0); Du: 0(3.23401e-05) 2s
Solving the original LP from the solution after postsolve
Using EKK primal simplex solver
Iteration Objective Infeasibilities num(sum)
390 -9.8922096347e+06 Pr: 0(0); Du: 17(0.000294) 2s
392 -9.8922096347e+06 Pr: 0(0); Du: 0(2.94003e-05) 2s
Model status : Optimal
Simplex iterations: 392
Objective value : -9.8922096347e+06
HiGHS run time : 2.47
Again, I understand that this is not a HiGHS issue in itself, but looking at the log differences I wonder if you could make some experienced observations. Thank you!
PS (sorry if this is too much information!) With log_dev_level
=3, I see a different log pattern starting around iteration 315… and notice how iteration 321 gets into endless loop to 329 and back:
DuPh2 315 -9.8922544906e+06
Iteration Objective Infeasibilities num(sum)
DuPh2 315 -9.8922544942e+06 Pr: 0(0); Du: 0(9.59158e-06) Synthetic clock
dual-phase-2-optimal
dual-cleanup-shift
Iteration Objective Infeasibilities num(sum)
DuPh2 315 -9.8922094863e+06 Pr: 0(0); Du: 11(0.00526849) Perturbation cleanup
HEkkDual:: Using primal simplex to try to clean up num / max / sum = 11 / 0.00150528 / 0.00526849 dual infeasibilities
primal-phase2-start
Iteration Objective Infeasibilities num(sum)
PrPh2 315 -9.8922094863e+06 Pr: 0(0); Du: 11(0.00526849) No reason
Iteration Objective
PrPh2 316 -9.8922094863e+06
PrPh2 317 -9.8922095206e+06
PrPh2 318 -9.8922095231e+06
PrPh2 319 -9.8922095921e+06
PrPh2 320 -9.8922095921e+06
PrPh2 321 -9.8922096347e+06
Iteration Objective Infeasibilities num(sum)
PrPh2 321 -9.8922096347e+06 Pr: 0(0); Du: 0(9.7114e-09) Possibly optimal
primal-phase-2-optimal
problem-optimal
Simplex iterations: DuPh2 315; PrPh2 6; Total 321
EKK dual simplex solver returns 0 primal and 0 dual infeasibilities: Status Optimal
Have num/max/sum primal (11/0.000985222/0.00263214) and dual (0/6.62359e-12/4.58177e-11) unscaled infeasibilities
Using EKK parallel dual simplex solver - PAMI with concurrency of 8
Dual feasible with unperturbed costs and num / max / sum primal infeasibilities of 11 / 0.000985222 / 0.00263214, so near-optimal
Near-optimal, so don't use cost perturbation
dual-phase-2-start
Iteration Objective Infeasibilities num(sum)
DuPh2 321 -9.8922096347e+06 Pr: 11(0.00263214); Du: 0(4.58177e-11) No reason
Iteration Objective
DuPh2 322 -9.8922096347e+06
DuPh2 323 -9.8922096347e+06
DuPh2 324 -9.8922096347e+06
DuPh2 325 -9.8922096347e+06
DuPh2 326 -9.8922096347e+06
DuPh2 327 -9.8922096347e+06
DuPh2 328 -9.8922096347e+06
Iteration Objective Infeasibilities num(sum)
DuPh2 321 -9.8922096347e+06 Pr: 11(0.00263214); Du: 0(4.58191e-11) Possibly singular basis
DuPh2 322 -9.8922096347e+06
DuPh2 323 -9.8922096347e+06
DuPh2 324 -9.8922096347e+06
DuPh2 325 -9.8922096347e+06
DuPh2 326 -9.8922096347e+06
DuPh2 327 -9.8922096347e+06
DuPh2 328 -9.8922096347e+06
DuPh2 329 -9.8922096347e+06
WARNING: Increasing Markowitz threshold to 0.5
Iteration Objective Infeasibilities num(sum)
DuPh2 321 -9.8922096347e+06 Pr: 11(0.00263214); Du: 0(4.58191e-11) Possibly singular basis
DuPh2 322 -9.8922096347e+06
...
(and so on and on and on)
Would you mind sharing the MPS file, particularly if you observe this issue when you debug in VSCode? I am wondering if I can replicate the hanging behaviour if I try to solve the MPS file from our C++ generated executable directly. The occasional hanging may be related to the threads bug on Windows, which is now observed both from Julia and Python and now C#. It must be something in the C++ code underneath the wrappers and it would be very helpful if I can replicate this
@galabovaa thank you for looking into this! Here's the mps file that caused this issue back in January: LP-problem.zip
Please note that since then we've changed our logic to calling highs.exe instead of calling the DLL from C#, as the DLL proved to be too unreliable for production usage. The .exe has its issues too, as you noted in the other ticket.
Hello,
I'm really struggling to pinpoint this issue. When I call HiGHS solver from my application, for one specific (very simple!) problem, the optimisation time is much higher than expected. Yet if I try to debug or reproduce it, it works fine. Perhaps you could help me see where the issue is (…or not).
This is on Windows 11, calling via C# interface, but for debugging I call in the same conditions (from what I can tell!).
The input .mps file attached: too-slow-2023-12-11.zip
I've set
log_dev_level
to 3, but comparing the two log files I can't see any difference between one an another case (apart from the time, of course).Here's the “slow” log:
Via file compare, the only difference with the “fast” (debug) log is this:
I'm quite puzzled by this, and would greatly appreciate any feedback.