use of aima.core.search.local.SimulatedAnnealingSearch in project aima-java by aimacode.
the class SimulatedAnnealingMaximumFinderApp method simulate.
/** Starts the experiment. */
@SuppressWarnings("unchecked")
public void simulate() {
List<Action> actions = new ArrayList<>(1);
actions.add(new DynamicAction("Move"));
Problem<Double, Action> problem = new GeneralProblem<>(getRandomState(), s -> actions, (s, a) -> getSuccessor(s), s -> false);
Function<Double, Double> func = (Function<Double, Double>) simPaneCtrl.getParamValue(PARAM_FUNC_SELECT);
Scheduler scheduler = new Scheduler(simPaneCtrl.getParamAsInt(PARAM_K), simPaneCtrl.getParamAsDouble(PARAM_LAMBDA), simPaneCtrl.getParamAsInt(PARAM_MAX_ITER));
search = new SimulatedAnnealingSearch<>(n -> 1 - func.apply(n.getState()), scheduler);
search.addNodeListener(n -> updateStateView(n.getState()));
search.findActions(problem);
updateStateView(search.getLastSearchState());
}
Aggregations