- java.lang.Object
-
- org.logicng.solvers.functions.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,nullwill be returned.Optimization functions are instantiated via their builder
builder().- Since:
- 2.0.0
- Version:
- 2.1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOptimizationFunction.BuilderThe builder for an optimization function.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Assignmentapply(MiniSat solver, Consumer<Tristate> resultSetter)Applies this function to the given solver.static OptimizationFunction.Builderbuilder()Returns the builder for this function.static OptimizationFunctionmaximize(Collection<? extends Literal> literals)Returns an optimization function which maximizes the given set of literals.static OptimizationFunctionminimize(Collection<? extends Literal> literals)Returns an optimization function which minimizes the given set of literals.
-
-
-
Method Detail
-
builder
public static OptimizationFunction.Builder builder()
Returns the builder for this function.- Returns:
- the builder
-
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:SolverFunctionApplies this function to the given solver.- Specified by:
applyin interfaceSolverFunction<Assignment>- Parameters:
solver- the solver on which the function should work onresultSetter- a setter for the result of the solver- Returns:
- the result of the function application
-
-