Quilt Loader 1
Loading...
Searching...
No Matches
org.quiltmc.loader.impl.solver.Sat4jWrapper Class Reference

A wrapper around sat4j. More...

Inheritance diagram for org.quiltmc.loader.impl.solver.Sat4jWrapper:
org.quiltmc.loader.api.plugin.solver.RuleContext

Classes

class  RuleDefinerInternal
class  Sat4jSolver
 Contains the actual Sat4j fields for computation.

Public Member Functions

void resetStage ()
 Clears out this Sat4jWrapper of all data EXCEPT the added Rules and LoadOptions.
void addOption (LoadOption option)
 Adds a new LoadOption, without any weight.
void setWeight (LoadOption option, Rule key, int weight)
 Sets the weight of an existing LoadOption, applied by the given rule.
void removeOption (LoadOption option)
void addRule (Rule rule)
 Adds a new Rule to this solver.
void removeRule (Rule rule)
void redefine (Rule rule)
 Clears any current definitions this rule is associated with, and calls Rule#define(RuleDefiner) sometime before solving.
boolean hasSolution () throws TimeoutException, ModSolvingError
 Attempts to find a solution.
Collection< RulegetError () throws TimeoutException
Collection< LoadOptiongetSolution () throws TimeoutException, ModSolvingError
 Computes and returns the optimised solution.
void cancel ()
 Cancels any current and future operation.
void appendRules (StringBuilder sb)
 Appends all current rules and options using the SolverPreProcessor format.

Additional Inherited Members

Static Public Member Functions inherited from org.quiltmc.loader.api.plugin.solver.RuleContext
static boolean isNegated (LoadOption option)
static LoadOption negate (LoadOption option)

Detailed Description

A wrapper around sat4j.

We use this instead of DependencyHelper since that's a bit more limited.

Solving happens in x stages:

  1. Create the solver
  2. Define rules in the solver
  3. Attempt to solve the rules.
  4. Perform optimisation of the rules.

This is (mostly) separated from any more specific rules

Member Function Documentation

◆ addOption()

void org.quiltmc.loader.impl.solver.Sat4jWrapper.addOption ( LoadOption option)
inline

Adds a new LoadOption, without any weight.

Implements org.quiltmc.loader.api.plugin.solver.RuleContext.

◆ addRule()

void org.quiltmc.loader.impl.solver.Sat4jWrapper.addRule ( Rule rule)
inline

Adds a new Rule to this solver.

This calls Rule#onLoadOptionAdded(LoadOption) for every LoadOption currently held, and calls Rule#define(RuleDefiner) once afterwards.

Implements org.quiltmc.loader.api.plugin.solver.RuleContext.

◆ getError()

Collection< Rule > org.quiltmc.loader.impl.solver.Sat4jWrapper.getError ( ) throws TimeoutException
inline
Returns
The error that prevented hasSolution() from returning true.
Exceptions
IllegalStateExceptionif the last call to hasSolution() didn't return false, or if any other methods have been called since the last call to hasSolution().

◆ getSolution()

Collection< LoadOption > org.quiltmc.loader.impl.solver.Sat4jWrapper.getSolution ( ) throws TimeoutException, ModSolvingError
inline

Computes and returns the optimised solution.

Returns
The solution.
Exceptions
TimeoutExceptionif the optimisation was cancelled before it completed. This will only be thrown if it hasn't computed any solutions when it is cancelled.
IllegalStateExceptionif hasSolution() didn't just return true, or if any other methods have been called since the last call to hasSolution().

◆ hasSolution()

boolean org.quiltmc.loader.impl.solver.Sat4jWrapper.hasSolution ( ) throws TimeoutException, ModSolvingError
inline

Attempts to find a solution.

If this returns true then you should call getSolution() to get it, otherwise call getError() to get the first reason why this doesn't have a solution.

Returns
True if a solution could be found, or false if one could not.

◆ redefine()

void org.quiltmc.loader.impl.solver.Sat4jWrapper.redefine ( Rule rule)
inline

Clears any current definitions this rule is associated with, and calls Rule#define(RuleDefiner) sometime before solving.

Implements org.quiltmc.loader.api.plugin.solver.RuleContext.

◆ removeOption()

void org.quiltmc.loader.impl.solver.Sat4jWrapper.removeOption ( LoadOption option)
inline

◆ setWeight()

void org.quiltmc.loader.impl.solver.Sat4jWrapper.setWeight ( LoadOption option,
Rule key,
int weight )
inline

Sets the weight of an existing LoadOption, applied by the given rule.

Parameters
keyThe rule which provides the weight modifier. May be null. If not null then this weight modifier will be removed whenever the rule is removed.
weightThe weight. Negative values will mean the solver will try to include the option, positive values encourage the solver to pick a different option. Absolute values are unimportant when only 1 of a set of options can be chosen, instead only relative will be important. The sum of all weights is used when solving.
Exceptions
IllegalArgumentExceptionif the given LoadOption isn't present.

Implements org.quiltmc.loader.api.plugin.solver.RuleContext.


The documentation for this class was generated from the following file:
  • src/main/java/org/quiltmc/loader/impl/solver/Sat4jWrapper.java