Class Solver

java.lang.Object
org.tweetyproject.math.opt.solver.Solver
Direct Known Subclasses:
ApacheCommonsCMAESOptimizer, ApacheCommonsNonLinearConjugateGradientOptimizer, ApacheCommonsSimplex, BfgsSolver, CombinatoricsSolver, GlpkSolver, GradientDescent, GurobiOptimizer, HessianGradientDescent, IteratedLocalSearchOnConstrProb, LagrangeSolver, LpSolve, OctaveSqpSolver, SimpleGeneticOptimizationSolver, SimulatedAnnealingOnConstrProb, StochasticLocalSearchOnConstrProb, TabuSearchOnConstrProb

public abstract class Solver extends Object
This abstract class models an abstract solver for constraint satisfaction or optimization problems.
Author:
Matthias Thimm
  • Constructor Details

    • Solver

      public Solver()
  • Method Details

    • setDefaultGeneralSolver

      public static void setDefaultGeneralSolver(Solver solver)
      Sets the default solver for non-linear (general) optimization problems.
      Parameters:
      solver - some solver
    • setDefaultLinearSolver

      public static void setDefaultLinearSolver(Solver solver)
      Sets the default solver for linear optimization problems.
      Parameters:
      solver - some solver
    • setDefaultIntegerLinearSolver

      public static void setDefaultIntegerLinearSolver(Solver solver)
      Sets the default solver for integer linear optimization problems.
      Parameters:
      solver - some solver
    • hasDefaultGeneralSolver

      public static boolean hasDefaultGeneralSolver()
      Returns "true" if a default solver for general optimization problems is configured.
      Returns:
      "true" if a default solver for general optimization problems is configured.
    • hasDefaultLinearSolver

      public static boolean hasDefaultLinearSolver()
      Returns "true" if a default solver for linear optimization problems is configured.
      Returns:
      "true" if a default solver for linear optimization problems is configured.
    • hasDefaultIntegerLinearSolver

      public static boolean hasDefaultIntegerLinearSolver()
      Returns "true" if a default solver for integer linear optimization problems is configured.
      Returns:
      "true" if a default solver for integer linear optimization problems is configured.
    • getDefaultGeneralSolver

      public static Solver getDefaultGeneralSolver()
      Returns the default solver for non-linear (general) optimization problems. If a default solver for general problems has been configured this solver is returned by this method. If no default solver for general problems is configured, a message is printed to stderr pointing out that no default solver is configured and the application is terminated.
      Returns:
      the default solver for non-linear (general) optimization problems.
    • getDefaultIntegerLinearSolver

      public static Solver getDefaultIntegerLinearSolver()
      Returns the default solver for integer linear optimization problems. If a default solver for general problems has been configured this solver is returned by this method. If no default solver for general problems is configured, a message is printed to stderr pointing out that no default solver is configured and the application is terminated.
      Returns:
      the default solver for non-linear (general) optimization problems.
    • getDefaultLinearSolver

      public static Solver getDefaultLinearSolver()
      Returns the default solver for linear optimization problems.

      If a default solver for linear problems has been configured this solver is returned by this method. If no default solver for linear problems is configured, the default solver for general optimization problems is returned. If this one is not defined as well, the ApacheCommonsSimplex solver (org.tweetyproject.math.opt.solver.ApacheCommonsSimplex) is returned (with a default setting of 50000 number of iterations that returns both positive and non-positive results) as a fallback and message is printed to stderr pointing out that no default solver is configured.
      Returns:
      the default solver for linear optimization problems.
    • solve

      public abstract Map<Variable,​Term> solve(GeneralConstraintSatisfactionProblem problem) throws GeneralMathException
      Computes a solution to the given constraint satisfaction or optimization problem, i.e. a mapping from variables of the problem to terms.
      Parameters:
      problem - the actual problem
      Returns:
      a mapping from variables of the problem to terms.
      Throws:
      GeneralMathException - if something went wrong.
    • isInstalled

      public static boolean isInstalled() throws UnsupportedOperationException
      Checks whether the solver of this class is actually installed, i.e. whether external binaries needed for running the solver are available and dependencies are satisfied.
      Returns:
      "true" if the solver of this class is installed and can therefore be instantiated and used.
      Throws:
      UnsupportedOperationException - if the operation is not supported