[rules-users] modifying the problem facts while running the solver - Drools Planner

Garf JonGarfunkel at gmail.com
Wed Aug 15 14:30:04 EDT 2012


spinjala wrote
> 
> 1) When a solution violates all constraints, does it provide a default
> solution? If so, can it be changed so that it doesn't provide one?
> Otherwise, is there a way to assure that no solution is generated when ALL
> constraints are violated. 
> 

Let's walk through the code. 
Solver.solve() will look for solutions until any of the conditions specified
by the termination configuration are met. These could be based on time, or
score, etc.

In your case, your best solution will have a negative hard score. You would
find this via:

Solution Sol = solver.getBestSolution();
if (Sol.getScore().getHardScore() == 0) {
  // no constraints are violated
} else {
  // Sol = null
}


spinjala wrote
> 
> 2) When a feasible solution is not generated, is it possible to make a
> custom solution as the most relevant solution instead of the generated
> one? For ex. if the solution generated by Drools planner assigned a work
> order WO2 to a resource R1, is it possible to create a custom solution
> that assigns it to, possibly R2?
> 

Sharpen your grammar here.
Your first sentence's first clause says that the feasible solution is not
generated, but the last clause references "the generated one."

So who (or what) is making this custom solution?
Remember that the Solution is your class. You are free to write your own
code to fill it on your own via your own code (or user actions).

Jon



--
View this message in context: http://drools.46999.n3.nabble.com/modifying-the-problem-facts-while-running-the-solver-Drools-Planner-tp4019099p4019154.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list