Class GurobiOptimizer
java.lang.Object
org.tweetyproject.math.opt.solver.Solver
org.tweetyproject.math.opt.solver.GurobiOptimizer
This class is a wrapper for the Gurobi optimizer
(https://www.gurobi.com). Works with Gurobi 9.1.0
- Author:
- Sebastian Franke, Matthias Thimm
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
parses a statement into a gurobi constrant and adds it to the modelstatic boolean
Return if solver is installedgurobi.GRBExpr
parses a term from tweety to GRB the input term needs to be linear or quadraticvoid
parseVars
(OptimizationProblem prob) takes all Variables from a tweety problem and maps them to GRB VaraiblesComputes a solution to the given constraint satisfaction or optimization problem, i.e.Returns the variable assignment that maximizes/minimizes the given term (which only contains variables with defined upper and lower bounds).Return a list of products from a quadratic term in normal formMethods inherited from class org.tweetyproject.math.opt.solver.Solver
getDefaultGeneralSolver, getDefaultIntegerLinearSolver, getDefaultLinearSolver, hasDefaultGeneralSolver, hasDefaultIntegerLinearSolver, hasDefaultLinearSolver, setDefaultGeneralSolver, setDefaultIntegerLinearSolver, setDefaultLinearSolver
-
Constructor Details
-
GurobiOptimizer
public GurobiOptimizer() throws gurobi.GRBExceptionConstructor- Throws:
gurobi.GRBException
- GRBException
-
-
Method Details
-
parseVars
takes all Variables from a tweety problem and maps them to GRB Varaibles- Parameters:
prob
- problem- Throws:
gurobi.GRBException
- GRBException
-
parseTerm
parses a term from tweety to GRB the input term needs to be linear or quadratic- Parameters:
term
- term- Returns:
- gurobi expression
-
addStatementToGurobi
parses a statement into a gurobi constrant and adds it to the model- Parameters:
s
- statement to be addedi
- running number of the constraint to be put into the Gurobi name of the constraint- Throws:
gurobi.GRBException
- GRBException
-
solve
public Map<Variable,Term> solve(GeneralConstraintSatisfactionProblem problem) throws GeneralMathException Description copied from class:Solver
Computes a solution to the given constraint satisfaction or optimization problem, i.e. a mapping from variables of the problem to terms.- Specified by:
solve
in classSolver
- Parameters:
problem
- the actual problem- Returns:
- a mapping from variables of the problem to terms.
- Throws:
GeneralMathException
- if something went wrong.
-
solve
public Map<Variable,Term> solve(Term t, int optimization_type) throws GeneralMathException, gurobi.GRBException Returns the variable assignment that maximizes/minimizes the given term (which only contains variables with defined upper and lower bounds).- Parameters:
t
- the term to be evaluatedoptimization_type
- one of OptimizationProblem.MAXIMIZE, OptimizationProblem.MINIMIZE- Returns:
- the optimal variable assignment
- Throws:
GeneralMathException
- if there is some issue in the computationgurobi.GRBException
- GRBException
-
toQuadraticFormHelper
-
isInstalled
Return if solver is installed- Returns:
- if solver is installed
- Throws:
UnsupportedOperationException
- UnsupportedOperationException
-