Closed m-abdullah-nabeel closed 1 year ago
For what it's worth, I've handled this by adding a constraint per variable:
var javascriptLpSolver = require("javascript-lp-solver")
model = {
"optimize": "price",
"opType": "min",
"constraints": {
"cp": {"equal": 15},
"me": {"equal": 2000},
"maize" : {"min": 40, "max": 70}
},
"variables": {
"maize": {"cp": 8, "me": 3350, "price": 15, "maize": 1},
"riceTips": {"cp": 8, "me": 3450, "price": 16, "riceTips": 1},
"sorghum": {"cp": 12, "me": 3300, "price": 22, "sorghum": 1},
"csc": {"cp": 41, "me": 3500, "price": 90, "csc": 1},
}
}
console.log(javascriptLpSolver.Solve(model));
I tried a lot of things at this time, but using this same data, I am able to get results using the python library Scipy under linprog module and which has more flexibility, I found that this jsLPSolver doesn't currently provide a solution for constraints effectively. So I migrated to backend in python
I am working on a linear programming problem, which is about combining all available feedstuffs such that they cost very low (minimize the cost/price) and also maximize the availability of the nutrients of proteins and energy. All of this is doable, but I am wondering how I would be able to implement the bounds process as I am able to do it in Python
scipy.optimize.linprog
, where we can implement a minimum and maximum for each variable in the bounds variable asres = linprog(c, A_ub=A, b_ub=b, bounds=bounds=[x0_bounds, x1_bounds, x2_bounds, x3_bounds])
where each bound is likex0_bounds = (10, 50)
and it implies the variable x0 can be minimum of 10 and maximum of 50, but if we go with the javascript solutions, I didn't find any implementation of this, as I would expect this to be