JWally / jsLPSolver

Simple OOP javaScript library to solve linear programs, and mixed integer linear programs
The Unlicense
420 stars 69 forks source link

Memory leak / Solver freezing #44

Closed ghost closed 8 years ago

ghost commented 8 years ago

It's odd. I can't tell if this is a memory leak issue or a solver issue. It appears that enabling Ints for these variables causes the solver to slip into an infinite loop.

Other times, if the constraints are a little different, it will solve it within 4 seconds; however, if I run again, it will go into an infinite loop (or so it appears).

Below is the JSON-stringify version of the model:

{"optimize":"totalCost","opType":"max","variables":{"Tanks":{"Dollers":95,"Goats":75,"Land":40,"Air":40,"totalCost":210},"Aircrafts":{"Dollers":145,"Goats":70,"Land":85,"Air":40,"totalCost":300},"Cars":{"Dollers":130,"Goats":120,"Land":170,"Air":70,"totalCost":420},"Horses":{"Dollers":370,"Goats":270,"Land":290,"Air":75,"totalCost":930},"Motorcycles":{"Dollers":450,"Goats":515,"Land":480,"Air":80,"totalCost":1445},"Dogs":{"Dollers":1000,"Goats":300,"Land":350,"Air":70,"totalCost":1650}},"constraints":{"Dollers":{"max":39599},"Goats":{"max":37025},"Land":{"max":38234},"Air":{"max":66400}},"ints":{"Tanks":1,"Aircrafts":1,"Cars":1,"Horses":1,"Motorcycles":1,"Dogs":1}}

ghost commented 8 years ago

And other addition, it looks like it is more of an issue when the constraints are large (35k+). When they're low (<=20k), then all works fine, and it's relatively quick.

I'm using master version btw.

lvenerosy commented 8 years ago

Hi, I am not sure I understand about this point :

Other times, if the constraints are a little different, it will solve it within 4 seconds; however, if I run again, it will go into an infinite loop (or so it appears).

Does the same model gives different runtime behaviours from one execution to another ? Since the solver is deterministic it would be really puzzling.

Concerning your JSON model I get this result :

in 5.775604776 s 11609 'iterations' feasible? true result? 114850 { Motorcycles: 44, Cars: 63, Aircrafts: 52, Tanks: 35, Horses: 2 }

If you have a model that you think fell into an infinite loop I'd be glad to examine it.

ghost commented 8 years ago

Thanks for the reply!

This is the exact model that falls into the infinite loop. If I try to run it again, it will take > 5 mins, again will much longer. I'm doing this in Chrome, if that helps.

lvenerosy commented 8 years ago

I created a node server then I loaded the JSON and solved the model in an HTML file that I launched in Chrome :

solving: 6648.551ms 11609 "iterations" feasible? true result? 114850 Object {Motorcycles: 44, Cars: 63, Aircrafts: 52, Tanks: 35, Horses: 2}

Could you give me the files necessary to recreate your problem ?

ghost commented 8 years ago

It's odd, but I cannot reproduce the issue now. Perhaps there was a browser bug that it stumbled upon. Thanks for your responses! Amazing work too!