Quiero resolver una ecuación multivariable no lineal con valores discretos como este:
x*y + z + t - 10 = 0
con restricciones:
10 < x < 100
etc.
Estoy tratando de hacerlo con la biblioteca Choco, pero estoy un poco perdido. Encontré este código:
// 1. Create a Solver
Solver solver = new Solver("my first problem");
// 2. Create variables through the variable factory
IntVar x = VariableFactory.bounded("X", 0, 5, solver);
IntVar y = VariableFactory.bounded("Y", 0, 5, solver);
// 3. Create and post constraints by using constraint factories
solver.post(IntConstraintFactory.arithm(x, "+", y, "<", 5));
// 4. Define the search strategy
solver.set(IntStrategyFactory.lexico_LB(x, y));
// 5. Launch the resolution process
solver.findSolution();
//6. Print search statistics
Chatterbox.printStatistics(solver);
pero no entiendo dónde coloco mi ecuación.
Respuestas
1 para la respuesta № 1Sí, más precisamente debes descomponer tus ecuaciones en varias restricciones:
10 < x < 100
se convierte
solver.post(ICF.arithm(x,">",10));
solver.post(ICF.arithm(x,"<",100));
y
x*y + z + t - 10 = 0
se convierte
// x*y = a
IntVar a = VF.bounded("x*y",-25,25,solver);
solver.post(ICF.times(x,y,a);
// a+z+t=10
IntVar cst = VF.fixed(10,solver);
solver.post(ICF.sum(new IntVar[]{a,z,t},cst));
Mejor,
Póngase en contacto con nosotros para obtener más ayuda sobre Choco Solver: www.cosling.com
2 para la respuesta № 2
No he usado esta biblioteca antes, pero ¿tal vez deberías simplemente tratar tu ecuación como una restricción?