From e11bce7ad3e803e80883499fec0ad6e4540ffe43 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Tue, 30 Jun 2020 18:03:48 +0200 Subject: Add modified VIATRA-DSE version --- .../src/org/eclipse/viatra/dse/api/Strategies.java | 123 +++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Strategies.java (limited to 'Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Strategies.java') diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Strategies.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Strategies.java new file mode 100644 index 00000000..ed7a90da --- /dev/null +++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/Strategies.java @@ -0,0 +1,123 @@ +/******************************************************************************* + * Copyright (c) 2010-2014, Miklos Foldenyi, Andras Szabolcs Nagy, Abel Hegedus, Akos Horvath, Zoltan Ujhelyi and Daniel Varro + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-v20.html. + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.viatra.dse.api; + +import org.eclipse.viatra.dse.api.strategy.impl.BestFirstStrategy; +import org.eclipse.viatra.dse.api.strategy.impl.BreadthFirstStrategy; +import org.eclipse.viatra.dse.api.strategy.impl.DepthFirstStrategy; +import org.eclipse.viatra.dse.api.strategy.impl.FixedPriorityStrategy; +import org.eclipse.viatra.dse.api.strategy.impl.HillClimbingStrategy; +import org.eclipse.viatra.dse.api.strategy.interfaces.IStrategy; + +/** + * Helper class for instantiating strategies. To implement a new strategy use the {@link IStrategy} interface. + * + * @author Andras Szabolcs Nagy + * + */ +public final class Strategies { + + private Strategies() { + } + + /** + * Creates a depth-first search exploration strategy without a depth limit. + * + * @return The strategy. + * @see DepthFirstStrategy + */ + public static DepthFirstStrategy createDfsStrategy() { + return new DepthFirstStrategy(); + } + + /** + * Creates a depth-first search exploration strategy with a depth limit. A negative depth limit means no + * depth limit, zero means that it will check the initial state. + * + * @param depthLimit + * @return The strategy. + * @see DepthFirstStrategy + */ + public static DepthFirstStrategy createDfsStrategy(int depthLimit) { + return new DepthFirstStrategy(depthLimit); + } + + /** + * Creates a fixed priority exploration strategy without a depth limit. It is a depth-first search exploration + * strategy but from a current state it only explores the activations with the highest priority. Priorities can be + * defined on the strategy itself. + * + * @return The strategy. + * @see FixedPriorityStrategy + */ + public static FixedPriorityStrategy createFixedPriorityStrategy() { + return createFixedPriorityStrategy(-1); + } + + /** + * Creates a fixed priority exploration strategy with a depth limit, where a zero or negative depth limit means no + * depth limit. It is a depth-first search exploration strategy but from a current state it only explores the + * activations with the highest priority. Priorities can be defined on the strategy itself. + * + * @param depthLimit + * @return The strategy. + * @see FixedPriorityStrategy + */ + public static FixedPriorityStrategy createFixedPriorityStrategy(int depthLimit) { + return new FixedPriorityStrategy().withDepthLimit(depthLimit); + } + + /** + * Creates a breadth-first search exploration strategy without a depth limit. + * + * @return The strategy. + * @see BreadthFirstStrategy + */ + public static BreadthFirstStrategy createBfsStrategy() { + return new BreadthFirstStrategy(); + } + + /** + * Creates a breadth-first search exploration strategy with a depth limit. A zero or negative depth limit means no + * depth limit. + * + * @param depthLimit + * @return The strategy. + * @see BreadthFirstStrategy + */ + public static BreadthFirstStrategy createBfsStrategy(int depthLimit) { + return new BreadthFirstStrategy(depthLimit); + } + + /** + * Creates a hill climbing exploration strategy. By default, it explores all neighborhood states and chooses the + * best one to continue with until all neighborhood states are dominated by the current state. Other options are + * available on the strategy. + * + * @return The strategy. + * @see HillClimbingStrategy + */ + public static HillClimbingStrategy creatHillClimbingStrategy() { + return new HillClimbingStrategy(); + } + + /** + * See {@link BestFirstStrategy}. + */ + public static BestFirstStrategy createBestFirstStrategy() { + return new BestFirstStrategy(); + } + + /** + * See {@link BestFirstStrategy}. + */ + public static BestFirstStrategy createBestFirstStrategy(int depthLimit) { + return new BestFirstStrategy(depthLimit); + } +} -- cgit v1.2.3-54-g00ecf