CloudBalance unsolvedSolution = new CloudBalancingGenerator(true).createCloudBalance(100, 300);
session.setAttribute(CloudBalancingSessionAttributeName.SHOWN_SOLUTION, unsolvedSolution);
}
public void solve(final HttpSession session) {
final Solver solver = (Solver) session.getAttribute(CloudBalancingSessionAttributeName.SOLVER);
final CloudBalance unsolvedSolution = (CloudBalance) session.getAttribute(CloudBalancingSessionAttributeName.SHOWN_SOLUTION);
solver.addEventListener(new SolverEventListener<CloudBalance>() {
public void bestSolutionChanged(BestSolutionChangedEvent<CloudBalance> event) {
CloudBalance bestSolution = event.getNewBestSolution();
session.setAttribute(CloudBalancingSessionAttributeName.SHOWN_SOLUTION, bestSolution);
}
});
solvingExecutor.submit(new Runnable() {
public void run() {
solver.solve(unsolvedSolution);
}
});
}