Commit 367552d1 authored by Davis King's avatar Davis King

Polished the code a little.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403491
parent 9168329d
...@@ -34,7 +34,7 @@ namespace dlib ...@@ -34,7 +34,7 @@ namespace dlib
virtual scalar_type get_C ( virtual scalar_type get_C (
) const = 0; ) const = 0;
virtual long num_dimensions ( virtual long get_num_dimensions (
) const = 0; ) const = 0;
virtual void get_risk ( virtual void get_risk (
...@@ -144,11 +144,21 @@ namespace dlib ...@@ -144,11 +144,21 @@ namespace dlib
template < template <
typename matrix_type typename matrix_type
> >
void operator() ( typename matrix_type::type operator() (
const oca_problem<matrix_type>& problem, const oca_problem<matrix_type>& problem,
matrix_type& w matrix_type& w
) const ) const
{ {
// make sure requires clause is not broken
DLIB_ASSERT(problem.get_C() > 0 &&
problem.get_num_dimensions() > 0,
"\t void oca::operator()"
<< "\n\t The oca_problem is invalid"
<< "\n\t problem.get_C(): " << problem.get_C()
<< "\n\t problem.get_num_dimensions(): " << problem.get_num_dimensions()
<< "\n\t this: " << this
);
typedef typename matrix_type::type scalar_type; typedef typename matrix_type::type scalar_type;
typedef typename matrix_type::layout_type layout_type; typedef typename matrix_type::layout_type layout_type;
typedef typename matrix_type::mem_manager_type mem_manager_type; typedef typename matrix_type::mem_manager_type mem_manager_type;
...@@ -161,7 +171,7 @@ namespace dlib ...@@ -161,7 +171,7 @@ namespace dlib
vect_type temp, alpha, w_cur; vect_type temp, alpha, w_cur;
w.set_size(problem.num_dimensions(), 1); w.set_size(problem.get_num_dimensions(), 1);
w = 0; w = 0;
w_cur = w; w_cur = w;
...@@ -274,6 +284,7 @@ namespace dlib ...@@ -274,6 +284,7 @@ namespace dlib
// report current status // report current status
problem.optimization_status(best_obj, best_obj - cp_obj, planes.size()); problem.optimization_status(best_obj, best_obj - cp_obj, planes.size());
return best_obj;
} }
private: private:
......
...@@ -59,7 +59,7 @@ namespace dlib ...@@ -59,7 +59,7 @@ namespace dlib
- returns the C parameter - returns the C parameter
!*/ !*/
virtual long num_dimensions ( virtual long get_num_dimensions (
) const = 0; ) const = 0;
/*! /*!
ensures ensures
...@@ -74,7 +74,7 @@ namespace dlib ...@@ -74,7 +74,7 @@ namespace dlib
/*! /*!
requires requires
- is_col_vector(current_solution) == true - is_col_vector(current_solution) == true
- current_solution.size() == num_dimensions() - current_solution.size() == get_num_dimensions()
ensures ensures
- #current_solution will be set to one of the following: - #current_solution will be set to one of the following:
- current_solution (i.e. it won't be modified at all) - current_solution (i.e. it won't be modified at all)
...@@ -129,13 +129,17 @@ namespace dlib ...@@ -129,13 +129,17 @@ namespace dlib
template < template <
typename matrix_type typename matrix_type
> >
void operator() ( typename matrix_type::type operator() (
const oca_problem<matrix_type>& problem, const oca_problem<matrix_type>& problem,
matrix_type& w matrix_type& w
) const; ) const;
/*! /*!
requires
- problem.get_C() > 0
- problem.get_num_dimensions() > 0
ensures ensures
- solves the given oca problem and stores the solution in #w - solves the given oca problem and stores the solution in #w
- returns the objective value at the soltuion #w
!*/ !*/
void set_epsilon ( void set_epsilon (
......
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