summaryrefslogtreecommitdiff
path: root/gi/posterior-regularisation/prjava/src/optimization
diff options
context:
space:
mode:
Diffstat (limited to 'gi/posterior-regularisation/prjava/src/optimization')
-rw-r--r--gi/posterior-regularisation/prjava/src/optimization/gradientBasedMethods/AbstractGradientBaseMethod.java9
-rw-r--r--gi/posterior-regularisation/prjava/src/optimization/projections/SimplexProjection.java2
2 files changed, 6 insertions, 5 deletions
diff --git a/gi/posterior-regularisation/prjava/src/optimization/gradientBasedMethods/AbstractGradientBaseMethod.java b/gi/posterior-regularisation/prjava/src/optimization/gradientBasedMethods/AbstractGradientBaseMethod.java
index 0a4a5445..2fcb7990 100644
--- a/gi/posterior-regularisation/prjava/src/optimization/gradientBasedMethods/AbstractGradientBaseMethod.java
+++ b/gi/posterior-regularisation/prjava/src/optimization/gradientBasedMethods/AbstractGradientBaseMethod.java
@@ -56,9 +56,10 @@ public abstract class AbstractGradientBaseMethod implements Optimizer{
stats.collectInitStats(this, o);
direction = new double[o.getNumParameters()];
initializeStructures(o, stats, stop);
- for (currentProjectionIteration = 1; currentProjectionIteration < maxNumberOfIterations; currentProjectionIteration++){
-// System.out.println("starting iterations: parameters:" );
-// o.printParameters();
+ for (currentProjectionIteration = 1; currentProjectionIteration < maxNumberOfIterations; currentProjectionIteration++){
+ //System.out.println("\tgradient descent iteration " + currentProjectionIteration);
+ //System.out.print("\tparameters:" );
+ //o.printParameters();
previousValue = currValue;
currValue = o.getValue();
gradient = o.getGradient();
@@ -76,7 +77,7 @@ public abstract class AbstractGradientBaseMethod implements Optimizer{
updateStructuresBeforeStep(o, stats, stop);
lso.reset(direction);
step = lineSearch.getStepSize(lso);
-// System.out.println("Leave with step: " + step);
+ //System.out.println("\t\tLeave with step: " + step);
if(step==-1){
System.out.println("Failed to find step");
stats.collectFinalStats(this, o);
diff --git a/gi/posterior-regularisation/prjava/src/optimization/projections/SimplexProjection.java b/gi/posterior-regularisation/prjava/src/optimization/projections/SimplexProjection.java
index eec11bcf..f22afcaf 100644
--- a/gi/posterior-regularisation/prjava/src/optimization/projections/SimplexProjection.java
+++ b/gi/posterior-regularisation/prjava/src/optimization/projections/SimplexProjection.java
@@ -40,7 +40,7 @@ public class SimplexProjection extends Projection{
for (int i = 0; i < ds.length; i++) {
currentSum+=ds[i];
theta = (currentSum-scale)/(i+1);
- if(ds[i]-theta <= 0){
+ if(ds[i]-theta < -1e-10){
break;
}
previousTheta = theta;