Class Posterior
- java.lang.Object
-
- ch.idsia.crema.inference.approxlp2.Posterior
-
- All Implemented Interfaces:
ObjectiveFunction<Move,Solution>,Comparator<Solution>
public class Posterior extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static doubleBADprotected org.apache.commons.math3.optim.nonlinear.scalar.GoalTypegoalprotected GraphicalModel<? extends GenericFactor>modelprotected int[]sequenceprotected intx0protected intx0state
-
Constructor Summary
Constructors Constructor Description Posterior(GraphicalModel<? extends GenericFactor> model, org.apache.commons.math3.optim.nonlinear.scalar.GoalType dir, int x0, int x0state, gnu.trove.map.TIntIntMap evidence)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected BayesianFactorcalcMarginal(Solution sol, int[] query)protected BayesianFactorcalcPosterior(Solution sol, int[] query, gnu.trove.map.TIntIntMap ev)intcompare(Solution sol1, Solution sol2)protected LinearFractionalSolvercreateSolver(int free)doubleeval(Solution solution)This might and should be mapped to eval(solution, null); Evaluation of a solution should really be cached.doubleeval(Solution from, Move doing)Evaluate the value for a move and get the new vertexprotected voidfixNotMoving(Solution from, Move move)Make non vertex changing moves illegal.org.apache.commons.math3.optim.nonlinear.scalar.GoalTypegetGoal()protected BayesianFactorgetX0factor()This is a custom bayesian factor over x0 with a 1 for x0state.booleanisBound(double value)Test whether the provided score is a bound.booleanisImprovement(double change)since we did not specify if a positive change is good or bad here we can get that informationbooleanisImprovement(double from, double to)since we did not specify if a positive change is good or bad here we can get that information.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Field Detail
-
BAD
public static final double BAD
- See Also:
- Constant Field Values
-
model
protected GraphicalModel<? extends GenericFactor> model
-
goal
protected org.apache.commons.math3.optim.nonlinear.scalar.GoalType goal
-
x0
protected int x0
-
x0state
protected int x0state
-
sequence
protected int[] sequence
-
-
Constructor Detail
-
Posterior
public Posterior(GraphicalModel<? extends GenericFactor> model, org.apache.commons.math3.optim.nonlinear.scalar.GoalType dir, int x0, int x0state, gnu.trove.map.TIntIntMap evidence)
-
-
Method Detail
-
createSolver
protected LinearFractionalSolver createSolver(int free)
-
eval
public double eval(Solution from, Move doing)
Evaluate the value for a move and get the new vertexdoing- if null from will be evaluated- Returns:
-
eval
public double eval(Solution solution)
Description copied from interface:ObjectiveFunctionThis might and should be mapped to eval(solution, null); Evaluation of a solution should really be cached. This method might be called multiple times for a solution- Returns:
-
getGoal
public org.apache.commons.math3.optim.nonlinear.scalar.GoalType getGoal()
-
getX0factor
protected BayesianFactor getX0factor()
This is a custom bayesian factor over x0 with a 1 for x0state. The value is cached.- Returns:
-
fixNotMoving
protected void fixNotMoving(Solution from, Move move)
Make non vertex changing moves illegal.- Parameters:
from-move-
-
calcMarginal
protected BayesianFactor calcMarginal(Solution sol, int[] query)
-
calcPosterior
protected BayesianFactor calcPosterior(Solution sol, int[] query, gnu.trove.map.TIntIntMap ev)
-
compare
public int compare(Solution sol1, Solution sol2)
- Specified by:
comparein interfaceComparator<Solution>
-
isImprovement
public boolean isImprovement(double change)
Description copied from interface:ObjectiveFunctionsince we did not specify if a positive change is good or bad here we can get that information- Specified by:
isImprovementin interfaceObjectiveFunction<Move,Solution>- Returns:
-
isImprovement
public boolean isImprovement(double from, double to)Description copied from interface:ObjectiveFunctionsince we did not specify if a positive change is good or bad here we can get that information. If any of the inputs is NaN the other must be an improvement. If both are NaN it should not be an improvement.- Specified by:
isImprovementin interfaceObjectiveFunction<Move,Solution>- Returns:
-
isBound
public boolean isBound(double value)
Description copied from interface:ObjectiveFunctionTest whether the provided score is a bound. This will be used to test if we reached a known upper/lower bound and should not continue.- Specified by:
isBoundin interfaceObjectiveFunction<Move,Solution>- Parameters:
value- a score- Returns:
- true if the score is a bound in the optimizing direction
-
-