public class LambdaSolve
extends java.lang.Object
Modifier and Type  Field and Description 

protected double 
eps
Only used in the IIS optimization routines.

protected byte[][] 
fnumArr
This contains the number of features active for each pair (x,y)

protected double[] 
ftildeArr
This is an array of empirical expectations for the features

double[] 
lambda
These are the model parameters that have to be learned.

protected boolean[] 
lambda_converged
Only allocated and used in the IIS optimization routines.

protected Problem 
p 
protected double[][] 
probConds
Conditional probabilities.

boolean 
weightRanks 
protected double[] 
zlambda
Normalization factors, one for each x.

Constructor and Description 

LambdaSolve() 
LambdaSolve(Problem p1,
double eps1,
double nerr1) 
LambdaSolve(java.lang.String filename)
Reads the lambda parameters from a file.

Modifier and Type  Method and Description 

boolean 
checkCorrectness()
Check whether the constraints are satisfied, the probabilities sum to one, etc.

static double 
divide(double first,
double second)
Given a numerator and denominator in log form, this calculates
the conditional model probabilities.

double 
expectedValue()
Each pair x,y has a value in p.data.values[x][y]

protected double 
fnum(int x,
int y) 
double 
GainCompute(Feature f,
double errorGain)
Computes the gain from a feature.

double[] 
getDerivatives()
assuming we have the lambdas in the array and we need only the
derivatives now.

double[] 
getDerivativesExpectedValue()
assuming we have the probConds[x][y] , compute the derivatives for the expectedValue function

double[] 
getDerivativesLossDomination()
Using the arrays calculated when computing the loss, it should not be
too hard to get the derivatives.

double[] 
getDerivativesNeg()
assuming we have the lambdas in the array and we need only the
derivatives now.

void 
improvedIterative()
Iterate until convergence.

void 
improvedIterative(int iters)
Does a fixed number of IIS iterations.

double 
logLikelihood() 
double 
logLikelihoodNeg()
Calculate the loglikelihood from scratch, hashing the conditional
probabilities in pcond, which we will use later.

double 
logLikelihoodScratch()
calculate the log likelihood from scratch, hashing the conditional
probabilities in pcond which we will use for the derivative later.

double 
lossDomination()
calculate the loss for Dom ranking
using the numbers in p.data.values to determine domination relationships in the graphs
if values[x][y]> values[x][y'] then there is an edge (x,y)>(x,y')

static void 
main(java.lang.String[] args)
With arguments, this will print out the lambda parameters of a
bunch of .lam files (which are assumed to all be the same size).

double 
pcond(int y,
int x) 
void 
print()
Print out p(yx) for all pairs to the standard output.

static double[] 
read_lambdas(java.io.DataInputStream rf)
Read the lambdas from the stream.

void 
readL(java.lang.String filename)
Read the lambdas from the file.

static void 
save_lambdas(java.io.DataOutputStream rf,
double[] lambdas)
Writes the lambdas to a stream.

void 
save_lambdas(java.lang.String filename)
Writes the lambda feature weights to the file.

void 
setBinary() 
void 
setNonBinary() 
void 
transformValues()
This is a specialized procedure to change the values
of parses for semantic ranking.

public double[] lambda
protected boolean[] lambda_converged
protected double eps
protected Problem p
protected double[][] probConds
protected double[] zlambda
protected byte[][] fnumArr
protected double[] ftildeArr
public boolean weightRanks
public LambdaSolve(Problem p1, double eps1, double nerr1)
public LambdaSolve(java.lang.String filename)
filename
 File to read frompublic LambdaSolve()
public void setNonBinary()
public void setBinary()
public void transformValues()
public void improvedIterative()
public void improvedIterative(int iters)
iters
 Number of iterations to runpublic double pcond(int y, int x)
protected double fnum(int x, int y)
public boolean checkCorrectness()
public double GainCompute(Feature f, double errorGain)
public void print()
public void save_lambdas(java.lang.String filename)
filename
 The file to write the weights to.public static void save_lambdas(java.io.DataOutputStream rf, double[] lambdas)
public void readL(java.lang.String filename)
filename
 The file to read frompublic static double[] read_lambdas(java.io.DataInputStream rf)
rf
 Stream to read from.public double logLikelihood()
public static double divide(double first, double second)
public static void main(java.lang.String[] args)
args
 command line argumentspublic double logLikelihoodNeg()
public double logLikelihoodScratch()
public double[] getDerivatives()
public double[] getDerivativesNeg()
public double expectedValue()
public double[] getDerivativesExpectedValue()
public double lossDomination()
public double[] getDerivativesLossDomination()