Class DLVSolver

java.lang.Object
org.tweetyproject.lp.asp.reasoner.ASPSolver
org.tweetyproject.lp.asp.reasoner.DLVSolver
All Implemented Interfaces:
ModelProvider<ASPRule,Program,AnswerSet>, QualitativeReasoner<Program,ASPLiteral>, Reasoner<Boolean,Program,ASPLiteral>

public class DLVSolver extends ASPSolver
Wrapper class for the DLV answer set solver command line utility.
Author:
Thomas Vengels, Tim Janus, Anna Gessler
  • Constructor Details

    • DLVSolver

      public DLVSolver(String pathToDLV)
      Constructs a new instance pointing to a specific DLV solver.
      Parameters:
      pathToDLV - binary location of DLV on the hard drive. The given location has to contain a binary called "dlv". Do not include the binary itself in the path.
    • DLVSolver

      public DLVSolver(String pathToDLV, Shell bash)
      Constructs a new instance pointing to a specific DLV solver.
      Parameters:
      pathToDLV - binary location of DLV on the hard drive. The given location has to contain a binary called "dlv". Do not include the binary itself in the path.
      bash - shell to run commands
    • DLVSolver

      public DLVSolver(String pathToDLV, int maxNOfModels, int integerMaximum)
      Constructs a new instance pointing to a specific DLV solver.
      Parameters:
      pathToDLV - binary location of Clingo on the hard drive. The given location has to contain a binary called "clingo". Do not include the binary itself in the path.
      maxNOfModels - the maximum number of models that DLV will compute.
      integerMaximum - the integer maximum ("-N" parameter) that DLV will use
  • Method Details

    • getModels

      public Collection<AnswerSet> getModels(Program p, int maxInt)
      Returns a characterizing model (answer set) of the given belief base using the given upper integer limit.
      Overrides:
      getModels in class ASPSolver
      Parameters:
      p - a program
      maxInt - the max number of models to be returned
      Returns:
      AnswerSet
    • getModel

      public AnswerSet getModel(Program p, int maxInt)
      Returns a characterizing model (answer set) of the given belief base using the given upper integer limit.
      Overrides:
      getModel in class ASPSolver
      Parameters:
      p - a program
      maxInt - the max number of models to be returned
      Returns:
      AnswerSet
    • getModels

      public List<AnswerSet> getModels(Program p)
      Description copied from interface: ModelProvider
      Returns a characterizing model of the given belief base
      Specified by:
      getModels in interface ModelProvider<ASPRule,Program,AnswerSet>
      Specified by:
      getModels in class ASPSolver
      Parameters:
      p - some belief base
      Returns:
      the (selected) models of the belief base
    • getModels

      public List<AnswerSet> getModels(String p)
      Description copied from class: ASPSolver
      Returns a characterizing model (answer set) of the given belief base.
      Specified by:
      getModels in class ASPSolver
      Parameters:
      p - containing belief base
      Returns:
      AnswerSet
    • getModels

      public List<AnswerSet> getModels(File file)
      Description copied from class: ASPSolver
      Returns a characterizing model (answer set) of the given belief base.
      Specified by:
      getModels in class ASPSolver
      Parameters:
      file - containing belief base
      Returns:
      AnswerSet
    • getModel

      public AnswerSet getModel(Program p)
      Description copied from interface: ModelProvider
      Returns a single (dedicated) model of the given belief base. If the implemented method allows for more than one dedicated model, the selection may be non-deterministic.
      Parameters:
      p - some belief base
      Returns:
      a selected model of the belief base.
    • setOptions

      public void setOptions(String options)
      Set additional command line options for DLV.
      Parameters:
      options - a string of options
    • setPathToDLV

      public void setPathToDLV(String pathToDLV)
      Sets the location of the DLV solver on the hard drive.
      Parameters:
      pathToDLV - path to DLV
    • query

      public Boolean query(Program beliefbase, ASPLiteral formula)
      Description copied from interface: QualitativeReasoner
      Queries the given belief base with the provided formula and returns a boolean result. The result indicates whether the formula is entailed or satisfied by the belief base according to the qualitative reasoning method implemented by the reasoner.
      Specified by:
      query in interface QualitativeReasoner<Program,ASPLiteral>
      Specified by:
      query in interface Reasoner<Boolean,Program,ASPLiteral>
      Specified by:
      query in class ASPSolver
      Parameters:
      beliefbase - The belief base to be queried.
      formula - The formula for which the query is made.
      Returns:
      `TRUE` if the formula is entailed or satisfied by the belief base, `FALSE` otherwise.
    • query

      public Boolean query(Program beliefbase, ASPLiteral formula, InferenceMode inferenceMode)
      Evaluates a query on the given belief base using the specified inference mode.

      This method checks whether the given formula is entailed by the belief base under the specified inference mode. It retrieves the answer sets of the belief base and checks the presence of the formula in these sets based on the chosen inference mode, either skeptical or credulous.

      Parameters:
      beliefbase - The program representing the belief base to query.
      formula - The formula (literal) to be checked within the answer sets.
      inferenceMode - The mode of inference, either skeptical or credulous.
      Returns:
      true if the formula is entailed by the belief base under the specified inference mode, false otherwise.
    • isInstalled

      public boolean isInstalled()
      Description copied from interface: QualitativeReasoner
      Checks whether the underlying solver or reasoning mechanism used by this reasoner is installed and available for use. This can be helpful when the reasoner depends on external tools or libraries for performing the reasoning tasks.
      Returns:
      `true` if the solver is installed and available, `false` otherwise.