diff --git a/sm/csm/structprior/Constraint.cpp b/sm/csm/structprior/Constraint.cpp index 1e914a7f0efe07fa8b14c40b3b559ac21bf3ea1b..bae68a8ad615a1dc138146bfab20d3f1e6a53cf8 100644 --- a/sm/csm/structprior/Constraint.cpp +++ b/sm/csm/structprior/Constraint.cpp @@ -20,13 +20,26 @@ Values Constraint::ApplyConstraint(double alphas[], double params[]) { Values v; double err = 0; - double grd = 0; + double grd[3] = {0,0,0}; switch(type) { case EQUAL_TO_EITHER: { - + double e1 = 0.5*(alphas[1]-alphas[0]); + double e2 = 0.5*(alphas[2]-alphas[1]); + + if (e1 < e2) + { + err = e1; + + } + + else + { + err = e2; + } + break; } @@ -40,7 +53,8 @@ Values Constraint::ApplyConstraint(double alphas[], double params[]) } v.error = err; - v.grad = grd; + for (int i=0;i< 3;i++) + v.grad[i] = grd[i]; return v; } diff --git a/sm/csm/structprior/Constraint.h b/sm/csm/structprior/Constraint.h index a98a54a79533e9bd42aa95b2cfe044eedde6d6d5..3260aca8d50ebe3bc7ac148e9870e081d02b3cad 100644 --- a/sm/csm/structprior/Constraint.h +++ b/sm/csm/structprior/Constraint.h @@ -11,7 +11,7 @@ struct Values{ double error; - double grad; + double grad[]; };