summaryrefslogtreecommitdiff
path: root/gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java
diff options
context:
space:
mode:
authortrevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-14 15:15:35 +0000
committertrevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-14 15:15:35 +0000
commitd2a54056e2acbdfd48e7c088fe25cc24cf280575 (patch)
tree73589c6900293e34f12a3070ec80bef3398c9a99 /gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java
parentc29321deae3bc178e9ea0501f598a40894c6bc98 (diff)
Made PhraseObjective thread safe
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@248 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java')
-rw-r--r--gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java24
1 files changed, 11 insertions, 13 deletions
diff --git a/gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java b/gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java
index e62b62f4..7c32d9c0 100644
--- a/gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java
+++ b/gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java
@@ -25,7 +25,7 @@ public class PhraseObjective extends ProjectedObjective
static int ITERATIONS = 100;
//private double c1=0.0001; // wolf stuff
//private double c2=0.9;
- private static double lambda[][];
+ //private static double lambda[][];
private PhraseCluster c;
/**@brief
@@ -64,23 +64,18 @@ public class PhraseObjective extends ProjectedObjective
*/
public double llh;
- public PhraseObjective(PhraseCluster cluster, int phraseIdx, double scale){
+ public PhraseObjective(PhraseCluster cluster, int phraseIdx, double scale, double[] lambda){
phrase=phraseIdx;
c=cluster;
data=c.c.getEdgesForPhrase(phrase);
n_param=data.size()*c.K;
//System.out.println("Num parameters " + n_param + " for phrase #" + phraseIdx);
- if (lambda==null){
- lambda=new double[c.c.getNumPhrases()][];
- }
-
- if (lambda[phrase]==null){
- lambda[phrase]=new double[n_param];
- }
+ if (lambda==null)
+ lambda=new double[n_param];
- parameters=lambda[phrase];
- newPoint = new double[n_param];
+ parameters = lambda;
+ newPoint = new double[n_param];
gradient = new double[n_param];
initP();
projection=new SimplexProjection(scale);
@@ -163,8 +158,12 @@ public class PhraseObjective extends ProjectedObjective
public double [][]posterior(){
return q;
}
-
+
+ long optimizationTime;
+
public boolean optimizeWithProjectedGradientDescent(){
+ long start = System.currentTimeMillis();
+
LineSearchMethod ls =
new ArmijoLineSearchMinimizationAlongProjectionArc
(new InterpolationPickFirstStep(INIT_STEP_SIZE));
@@ -188,7 +187,6 @@ public class PhraseObjective extends ProjectedObjective
//}else{
// System.out.println("Failed to optimize");
//}
- lambda[phrase]=parameters;
// ps.println(Arrays.toString(parameters));
// for(int edge=0;edge<data.getSize();edge++){