Commit 50832ee5 authored by Davis King's avatar Davis King

Changed the oca_problem interface to the oca optimizer. Now the optimization_status()

function reports back the current risk and risk gap in addition to just the overall
objective value and objective gap.  Note that this change breaks backwards compatibility
with the previous interface (but only slightly).

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%404245
parent a56bab46
......@@ -26,6 +26,8 @@ namespace dlib
) const { return false; }
virtual bool optimization_status (
scalar_type ,
scalar_type ,
scalar_type ,
scalar_type ,
unsigned long,
......@@ -164,7 +166,6 @@ namespace dlib
unsigned long counter = 0;
while (true)
{
++counter;
// add the next cutting plane
scalar_type cur_risk;
......@@ -180,8 +181,16 @@ namespace dlib
else
alpha = join_cols(alpha,zeros_matrix<scalar_type>(1,1));
cur_obj = 0.5*trans(w)*w + C*cur_risk;
const scalar_type wnorm = 0.5*trans(w)*w;
cur_obj = wnorm + C*cur_risk;
// report current status
const scalar_type risk_gap = cur_risk - (cp_obj-wnorm)/C;
if (counter > 0 && problem.optimization_status(cur_obj, cur_obj - cp_obj,
cur_risk, risk_gap, planes.size(), counter))
{
break;
}
// compute kernel matrix for all the planes
K.swap(Ktmp);
......@@ -230,9 +239,6 @@ namespace dlib
// plane subproblem.
cp_obj = -0.5*trans(w)*w + trans(alpha)*vector_to_matrix(bs);
// report current status
if (problem.optimization_status(cur_obj, cur_obj - cp_obj, planes.size(), counter))
break;
// If it has been a while since a cutting plane was an active constraint then
// we should throw it away.
......@@ -248,6 +254,7 @@ namespace dlib
alpha = remove_row(alpha,idx);
}
++counter;
}
return cur_obj;
......
......@@ -49,6 +49,8 @@ namespace dlib
virtual bool optimization_status (
scalar_type current_objective_value,
scalar_type current_error_gap,
scalar_type current_risk_value,
scalar_type current_risk_gap,
unsigned long num_cutting_planes,
unsigned long num_iterations
) const = 0;
......@@ -59,8 +61,10 @@ namespace dlib
- current_error_gap == The bound on how much lower the objective function
can drop before we reach the optimal point. At the optimal solution the
error gap is equal to 0.
- num_cutting_planes == the number of cutting planes the algorithm is currently
using
- current_risk_value == the current value of the R(w) term of the objective function.
- current_risk_gap == the bound on how much lower the risk term can go. At the optimal
solution the risk gap is zero.
- num_cutting_planes == the number of cutting planes the algorithm is currently using.
- num_iterations == A count of the total number of iterations that have executed
since we started running the optimization.
ensures
......
......@@ -140,6 +140,8 @@ namespace dlib
virtual bool optimization_status (
scalar_type current_objective_value,
scalar_type current_error_gap,
scalar_type ,
scalar_type ,
unsigned long num_cutting_planes,
unsigned long num_iterations
) const
......
......@@ -72,6 +72,8 @@ namespace dlib
virtual bool optimization_status (
scalar_type current_objective_value,
scalar_type current_error_gap,
scalar_type ,
scalar_type ,
unsigned long num_cutting_planes,
unsigned long num_iterations
) const
......
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