Commit 2f4c6e49 authored by Mike Kremer's avatar Mike Kremer
Browse files

- Added second implementation of is_satisfied() and gradient_update_factor()...

- Added second implementation of is_satisfied() and gradient_update_factor() in order to grant backwards compatibility.

git-svn-id: http://www.openflipper.org/svnrepo/CoMISo/trunk@204 1355f012-dd97-4b2f-ae87-10fa9f823a57
parent 49aef7a2
......@@ -73,6 +73,17 @@ public:
return false;
}
virtual bool is_satisfied ( const double* _x, double _eps )
{
switch( type_)
{
case NC_EQUAL : return (fabs(eval_constraint(_x)) <= _eps); break;
case NC_LESS_EQUAL : return ( eval_constraint(_x) <= _eps); break;
case NC_GREATER_EQUAL: return ( eval_constraint(_x) >= -_eps); break;
}
return false;
}
// provide special properties
virtual bool is_linear() const { return false;}
virtual bool constant_gradient() const { return false;}
......@@ -96,6 +107,24 @@ public:
}
}
virtual double gradient_update_factor( const double* _x, double _eps )
{
double val = eval_constraint(_x);
bool upper_bound_ok = ( val <= _eps);
bool lower_bound_ok = ( val >= -_eps);
if(upper_bound_ok)
{
if(lower_bound_ok || type_ == NC_LESS_EQUAL) return 0.0;
else return 1.0;
}
else
{
if(lower_bound_ok && type_ == NC_GREATER_EQUAL) return 0.0;
else return -1.0;
}
}
private:
// constraint type
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment