|
|
Hi, I need a solver that can give me an exact solution to a bunch of quadratic constraints. What is the best solver to use for this purpose? I'm using ConstraintProgramming but i'm finding that it's too slow for even very simple constraints. Some examples of what I want are the following: Constraint: (x-1)(x-2) = 0 Desired solution: x = 1 (or x = 2, any one solution would do) Constraints: (x-1)(x-2) <= 0 and (x-1)(x-2) >= 0 Desired solution: x = 1 (or x = 2, any one solution would do) Constaint: (x + 1)(x + 1) < 0 Desired solution: Not satisfiable
|
|
|
|
Hi, Based on what is described in the post, we have a few suggestions:
- When using CP solvers to solve models of integer decisions, it is a good practice to restrict the domains of the integer decisions as tight as possible. CP solvers essentially explore the search space defined by the cartesian product of the domains of the decisions. Though we have developed many effective heuristics that explore this huge search space really fast, there will still be the case that the solvers will take a significant amount of time to finish the search. So it will help the solvers if the modeler could tighten the domains of the decisions.
- It's always a good idea to try out multiple directives with different settings at the same time. SFS will transparently schedule the solver(s) with different settings to run in parallel. This way, we get the performance of the most effective directive setting. In this case, we could pass multiple CP directives to the Solve call, each of which has a different VariableSelection or ValueSelection heuristic.
- In general, we can try to convert the model with quadratic constraints into LP/MILP models and use LP/MILP solvers instead. For example, the constraint (x-1)*(x-2) == 0 can be rewritten using SOS1 constraint as follows:
Model[
Decisions[
Reals[0, Infinity],
x,
y1,
y2
],
Constraints[
Constraint1 -> x-1 == y1,
Constraint2 -> x-2 == y2,
Constraint3 -> Sos1[1*y1 + 1*y2]
]
]
Please let us know if you have further questions. Thanks. Lengning
|
|
|
|
|