public class ILPInference extends Inference
ILPSolver
to solve a constrained inference problem. When
constructing an instance of this class in an LBJava source file, use one of the constructors that
does not specify a head object. The generated code will fill in the head object
automatically. The other constructor parameters are used to specify the ILP algorithm and enable
textual output of ILP variable descriptions to STDOUT
. Textual output of the ILP
problem itself is controlled by the ILPSolver
.Modifier and Type | Field and Description |
---|---|
protected int |
ID
The identification number for this object, used in debug file names.
|
protected HashMap |
indexMap
Used during ILP constraint generation.
|
protected static int |
nextID
Keeps the next ID number for objects of this class.
|
protected int |
returnIndex
Used during ILP constraint generation.
|
protected boolean |
returnNegation
Used during ILP constraint generation.
|
protected edu.illinois.cs.cogcomp.infer.ilp.ILPSolver |
solver
The ILP algorithm.
|
protected boolean |
tautology
This flag is set if the constraints turn out to be true in all cases.
|
protected boolean |
topLevel
Used during ILP constraint generation.
|
protected int |
verbosity
Verbosity level.
|
static int |
VERBOSITY_HIGH
A possible setting for
verbosity . |
static int |
VERBOSITY_LOW
A possible setting for
verbosity . |
static int |
VERBOSITY_NONE
A possible setting for
verbosity . |
constraint, head, variables
Constructor and Description |
---|
ILPInference()
Don't use this constructor, since it doesn't set an ILP algorithm.
|
ILPInference(edu.illinois.cs.cogcomp.infer.ilp.ILPSolver a)
Initializes the ILP algorithm, but not the head object.
|
ILPInference(edu.illinois.cs.cogcomp.infer.ilp.ILPSolver a,
int v)
Initializes the ILP algorithm, but not the head object.
|
ILPInference(Object h)
Don't use this constructor, since it doesn't set an ILP algorithm.
|
ILPInference(Object h,
edu.illinois.cs.cogcomp.infer.ilp.ILPSolver a)
Sets the head object and the ILP algorithm.
|
ILPInference(Object h,
edu.illinois.cs.cogcomp.infer.ilp.ILPSolver a,
int v)
Sets the head object and the ILP algorithm.
|
Modifier and Type | Method and Description |
---|---|
void |
addConstraint(FirstOrderConstraint c)
Adds a constraint to the inference.
|
protected int |
createVariable(String d)
Creates a new Boolean variable to represent the value of a subexpression of some constraint.
|
boolean |
equals(Object o)
Two
Inference objects are equal when they have the same run-time type and store
the same head object. |
int |
hashCode()
Simply returns the
head 's hash code. |
protected void |
infer()
Uses the provided ILP algorithm to solve the ILP proglem if it hasn't already been solved.
|
String |
valueOf(Learner c,
Object o)
Retrieves the value of the specified variable as identified by the classifier and the object
that produce that variable.
|
void |
visit(PropositionalAtLeast c)
Derived classes override this method to do some type of processing on constraints of the
parameter's type.
|
void |
visit(PropositionalConjunction c)
Derived classes override this method to do some type of processing on constraints of the
parameter's type.
|
void |
visit(PropositionalConstant c)
Derived classes override this method to do some type of processing on constraints of the
parameter's type.
|
void |
visit(PropositionalDisjunction c)
Derived classes override this method to do some type of processing on constraints of the
parameter's type.
|
void |
visit(PropositionalDoubleImplication c)
Derived classes override this method to do some type of processing on constraints of the
parameter's type.
|
void |
visit(PropositionalImplication c)
Derived classes override this method to do some type of processing on constraints of the
parameter's type.
|
void |
visit(PropositionalNegation c)
Derived classes override this method to do some type of processing on constraints of the
parameter's type.
|
void |
visit(PropositionalVariable c)
Derived classes override this method to do some type of processing on constraints of the
parameter's type.
|
exampleToString, getHead, getHeadFinderTypes, getHeadType, getNormalizer, getVariable, getVariable, satisfied, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitAll
public static final int VERBOSITY_NONE
verbosity
.public static final int VERBOSITY_LOW
verbosity
.public static final int VERBOSITY_HIGH
verbosity
.protected static int nextID
protected int ID
protected edu.illinois.cs.cogcomp.infer.ilp.ILPSolver solver
protected boolean tautology
protected int returnIndex
protected boolean returnNegation
returnIndex
is negated in its current context.protected HashMap indexMap
PropositionalVariable
objects. The keys associated with indexes of temporary
variables created during constraint translation are strings.protected boolean topLevel
protected int verbosity
VERBOSITY_NONE
produces no incidental output. If set to
VERBOSITY_LOW
, only timing information is printed on STDOUT
. If set to VERBOSITY_HIGH
, information mapping the generated ILP
variables to the first order variables they were generated from and their settings in the ILP
problem's solution is printed to STDOUT
.public ILPInference()
public ILPInference(edu.illinois.cs.cogcomp.infer.ilp.ILPSolver a)
a
- The ILP algorithm.public ILPInference(edu.illinois.cs.cogcomp.infer.ilp.ILPSolver a, int v)
a
- The ILP algorithm.v
- Sets the value of verbosity
.public ILPInference(Object h)
public ILPInference(Object h, edu.illinois.cs.cogcomp.infer.ilp.ILPSolver a)
h
- The head object.a
- The ILP algorithm.public void addConstraint(FirstOrderConstraint c)
c
- The constraint to add.protected void infer() throws Exception
public String valueOf(Learner c, Object o) throws Exception
valueOf
in class Inference
c
- The classifier producing the variable.o
- The object from which the variable is produced.Learner
's
discreteValue(Object)
method applied to the Object
is
returned.Exception
public boolean equals(Object o)
Inference
objects are equal when they have the same run-time type and store
the same head object. I.e., the ==
operator must return true
when
comparing the two head objects for this method to return true
.public int hashCode()
head
's hash code.hashCode
in class Object
Object.hashCode()
protected int createVariable(String d)
d
- A textual description of the subexpression whose value is represented by the new
variable.public void visit(PropositionalDoubleImplication c)
public void visit(PropositionalImplication c)
public void visit(PropositionalConjunction c)
public void visit(PropositionalDisjunction c)
public void visit(PropositionalAtLeast c)
public void visit(PropositionalNegation c)
public void visit(PropositionalVariable c)
public void visit(PropositionalConstant c)
Copyright © 2016. All rights reserved.