JacobFeldman
unread,Sep 6, 2011, 8:57:19 AM9/6/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to jsr...@googlegroups.com, patric...@ateji.com, verg...@gmail.com, Narendra...@emn.fr, Radoslaw Szymanek, Helmut Simonis, dee...@samsung.com, Werner Keil
Vivian,
One reason against "findAllSolutions" was that a "naive" user could be in a loop forever or will get an "out of memory" exception because a number of solutions may grow exponentially even for relatively small CSPs. We are saving all solutions as we go. However, you always may use something like solver.setMaxNumberOfSolutions(10) to stop your solution search after (or before) the first 10 solutions are found. There is also time limits that control time for one solution and for overall search.
Still from my perspective a better solution will be to give a user control over the way how he/she wants to organize the search using goals as building blocks. Look, for example, how Goal Programming allowed me to implement "findAllSolutions" in a quite intuitive way:
public Solution[] findAllSolutions() {
clearSolutions();
Goal searchGoal = combineSearchStrategies();
Goal addGoal = new GoalAddSolution(this);
Goal maxGoal = new GoalCheckMaxNumberOfSolutions(this);
Goal backtrackGoal = new GoalBacktrack(this);
Goal goal1 = searchGoal.and(addGoal);
Goal goal2 = maxGoal.or(backtrackGoal);
Goal goal = goal1.and(goal2);
execute(goal);
return getSolutions();
}
Now about the JSR-331 implementation. What you described is exactly how JSR331 is implemented. Look at the architectural picture:
I will think how to move my implementation of "findAllSolution" from the SolverWithGoals to the common level.
Best,
Jacob