Class GurobiOptimizer

java.lang.Object
org.tweetyproject.math.opt.solver.Solver
org.tweetyproject.math.opt.solver.GurobiOptimizer

public class GurobiOptimizer extends Solver
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 Details

    • GurobiOptimizer

      public GurobiOptimizer() throws gurobi.GRBException
      Throws:
      gurobi.GRBException - GRBException
  • Method Details

    • parseVars

      public void parseVars(OptimizationProblem prob) throws gurobi.GRBException
      takes all Variables from a tweety problem and maps them to GRB Varaibles
      Parameters:
      prob - problem
      Throws:
      gurobi.GRBException - GRBException
    • parseTerm

      public gurobi.GRBExpr parseTerm(Term term)
      parses a term from tweety to GRB the input term needs to be linear or quadratic
      Parameters:
      term - term
      Returns:
      gurobi expression
    • addStatementToGurobi

      public void addStatementToGurobi(Statement s, Integer i) throws gurobi.GRBException
      parses a statement into a gurobi constrant and adds it to the model
      Parameters:
      s - statement to be added
      i - running number of the constraint to be put into the Gurobi name of the constraint
      Throws:
      gurobi.GRBException - GRBException
    • solve

      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 class Solver
      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 evaluated
      optimization_type - one of OptimizationProblem.MAXIMIZE, OptimizationProblem.MINIMIZE
      Returns:
      the optimal variable assignment
      Throws:
      GeneralMathException - if there is some issue in the computation
      gurobi.GRBException - GRBException
    • toQuadraticFormHelper

      public ArrayList<Sum> toQuadraticFormHelper(Term sum)
      Parameters:
      sum - a quadratic term in normal form
      Returns:
      a list of products from a quadratic term in normal form
    • isInstalled

      public static boolean isInstalled() throws UnsupportedOperationException
      Returns:
      if solver is installed
      Throws:
      UnsupportedOperationException - UnsupportedOperationException