Module logicng

Class OptimizationFunction

  • All Implemented Interfaces:
    SolverFunction<Assignment>

    public final class OptimizationFunction
    extends Object
    implements SolverFunction<Assignment>
    A solver function for computing a model for the formula on the solver which has a global minimum or maximum of satisfied literals. If the formula is UNSAT or the optimization handler aborted the computation, null will be returned.

    Optimization functions are instantiated via their builder builder().

    Since:
    2.0.0
    Version:
    2.1.0
    • Method Detail

      • maximize

        public static OptimizationFunction maximize​(Collection<? extends Literal> literals)
        Returns an optimization function which maximizes the given set of literals.
        Parameters:
        literals - the literals to maximize
        Returns:
        the solver function
      • minimize

        public static OptimizationFunction minimize​(Collection<? extends Literal> literals)
        Returns an optimization function which minimizes the given set of literals.
        Parameters:
        literals - the literals to minimize
        Returns:
        the solver function
      • apply

        public Assignment apply​(MiniSat solver,
                                Consumer<Tristate> resultSetter)
        Description copied from interface: SolverFunction
        Applies this function to the given solver.
        Specified by:
        apply in interface SolverFunction<Assignment>
        Parameters:
        solver - the solver on which the function should work on
        resultSetter - a setter for the result of the solver
        Returns:
        the result of the function application