JWally / jsLPSolver

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

Creating Dependent Variables #87

Open ohninhoj opened 5 years ago

ohninhoj commented 5 years ago

Have to say this is a really great solver though I'm running into a little trouble creating a slightly complicated model.

Effectively I want to create some binary variables that are dependent on other binary variables.

For example I have core binary variables 'a','b','c' & 'd' and sub-variables 'a1','b1','c1','d1' What I want is that 'a1' can only be equal to or less than 'a' etc.

This way if 'a' is set to 1, then 'a1' can only be 0 or 1. If 'a' is set to 0, the 'a1' must also be 0.

In human terms my core binaries are selections for a football squad of 15 players out of a pool of ~100 options.

The sub-variable is weekly selection- ie. you can only pick a player from within your squad and perhaps he is expected to well one week and badly the next depending on fixtures.

I have gotten this working very quickly and well in Python using the Pulp module so I'm sure it is a linear problem- is it possible to replicate using jsLPSolver?

ohninhoj commented 5 years ago

I can get it to solve with a bit of a hack -creating a value which is positive when a player is picked in the squad and negative when included weekly decisions- eventually leading the value to be zero only if a player is included in all squads or in none.

However this only works while the model is not too big ~300 variables, ~200 constraints. Realistically I need it to solve for 1000 variables and almost 1000 constraints- I hope that's not too large for this solver

I might just move forward with a bespoke iterative approach and forget about this...

guywal commented 4 years ago

I can get it to solve with a bit of a hack -creating a value which is positive when a player is picked in the squad and negative when included weekly decisions- eventually leading the value to be zero only if a player is included in all squads or in none.

However this only works while the model is not too big ~300 variables, ~200 constraints. Realistically I need it to solve for 1000 variables and almost 1000 constraints- I hope that's not too large for this solver

I might just move forward with a bespoke iterative approach and forget about this...

@ohninhoj Hi, you said that you got this functionality to work with some hack. I am working on a problem which also requires a dependant variable but don't know how to make it work. Could you please share how you did it?

jason-linthwaite commented 1 year ago

+1 on this if you can share how you did it @ohninhoj thankyou !!