Search in sources :

Example 1 with SimulatedAnnealingSearch

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());
}
Also used : Color(javafx.scene.paint.Color) java.util(java.util) IntegrableApplication(aima.gui.fx.framework.IntegrableApplication) Canvas(javafx.scene.canvas.Canvas) Action(aima.core.agent.Action) GeneralProblem(aima.core.search.framework.problem.GeneralProblem) SimulationPaneBuilder(aima.gui.fx.framework.SimulationPaneBuilder) Function(java.util.function.Function) Platform(javafx.application.Platform) Scheduler(aima.core.search.local.Scheduler) Parameter(aima.gui.fx.framework.Parameter) Paint(javafx.scene.paint.Paint) SimulationPaneCtrl(aima.gui.fx.framework.SimulationPaneCtrl) FunctionPlotterCtrl(aima.gui.fx.views.FunctionPlotterCtrl) BorderPane(javafx.scene.layout.BorderPane) DynamicAction(aima.core.agent.impl.DynamicAction) Problem(aima.core.search.framework.problem.Problem) SimulatedAnnealingSearch(aima.core.search.local.SimulatedAnnealingSearch) Pane(javafx.scene.layout.Pane) Function(java.util.function.Function) Action(aima.core.agent.Action) DynamicAction(aima.core.agent.impl.DynamicAction) Scheduler(aima.core.search.local.Scheduler) DynamicAction(aima.core.agent.impl.DynamicAction) GeneralProblem(aima.core.search.framework.problem.GeneralProblem)

Aggregations

Action (aima.core.agent.Action)1 DynamicAction (aima.core.agent.impl.DynamicAction)1 GeneralProblem (aima.core.search.framework.problem.GeneralProblem)1 Problem (aima.core.search.framework.problem.Problem)1 Scheduler (aima.core.search.local.Scheduler)1 SimulatedAnnealingSearch (aima.core.search.local.SimulatedAnnealingSearch)1 IntegrableApplication (aima.gui.fx.framework.IntegrableApplication)1 Parameter (aima.gui.fx.framework.Parameter)1 SimulationPaneBuilder (aima.gui.fx.framework.SimulationPaneBuilder)1 SimulationPaneCtrl (aima.gui.fx.framework.SimulationPaneCtrl)1 FunctionPlotterCtrl (aima.gui.fx.views.FunctionPlotterCtrl)1 java.util (java.util)1 Function (java.util.function.Function)1 Platform (javafx.application.Platform)1 Canvas (javafx.scene.canvas.Canvas)1 BorderPane (javafx.scene.layout.BorderPane)1 Pane (javafx.scene.layout.Pane)1 Color (javafx.scene.paint.Color)1 Paint (javafx.scene.paint.Paint)1