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
This abstract class models an abstract solver for constraint satisfaction or optimization problems.
- Author:
- Matthias Thimm
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Solver
Returns the default solver for non-linear (general) optimization problems.static Solver
Returns the default solver for integer linear optimization problems.static Solver
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.static boolean
Returns "true" if a default solver for general optimization problems is configured.static boolean
Returns "true" if a default solver for integer linear optimization problems is configured.static boolean
Returns "true" if a default solver for linear optimization problems is configured.static boolean
Checks whether the solver of this class is actually installed, i.e.static void
setDefaultGeneralSolver
(Solver solver) Sets the default solver for non-linear (general) optimization problems.static void
setDefaultIntegerLinearSolver
(Solver solver) Sets the default solver for integer linear optimization problems.static void
setDefaultLinearSolver
(Solver solver) Sets the default solver for linear optimization problems.Computes a solution to the given constraint satisfaction or optimization problem, i.e.
-
Constructor Details
-
Solver
public Solver()
-
-
Method Details
-
setDefaultGeneralSolver
Sets the default solver for non-linear (general) optimization problems.- Parameters:
solver
- some solver
-
setDefaultLinearSolver
Sets the default solver for linear optimization problems.- Parameters:
solver
- some solver
-
setDefaultIntegerLinearSolver
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
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
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
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
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
-