MCPcopy Create free account
hub / github.com/davisking/dlib / oca_impl

Method oca_impl

dlib/optimization/optimization_oca.h:181–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179 typename matrix_type
180 >
181 typename matrix_type::type oca_impl (
182 const oca_problem<matrix_type>& problem,
183 matrix_type& w,
184 const matrix_type& prior,
185 bool have_prior,
186 unsigned long num_nonnegative,
187 unsigned long force_weight_to_1,
188 const double lasso_lambda
189 ) const
190 {
191 const unsigned long num_dims = problem.get_num_dimensions();
192
193 // make sure requires clause is not broken
194 DLIB_ASSERT(problem.get_c() > 0 &&
195 problem.get_num_dimensions() > 0 &&
196 0 <= lasso_lambda && lasso_lambda < 1,
197 "\t scalar_type oca::operator()"
198 << "\n\t The oca_problem is invalid"
199 << "\n\t problem.get_c(): " << problem.get_c()
200 << "\n\t problem.get_num_dimensions(): " << num_dims
201 << "\n\t lasso_lambda: " << lasso_lambda
202 << "\n\t this: " << this
203 );
204 if (have_prior)
205 {
206 DLIB_ASSERT(lasso_lambda == 0, "Solver doesn't support using a prior with lasso.");
207 DLIB_ASSERT(num_nonnegative == 0, "Solver doesn't support using a prior with non-negative constraints.");
208 }
209 else if (lasso_lambda != 0)
210 {
211 DLIB_ASSERT(num_nonnegative == 0, "Solver doesn't support using lasso with non-negative constraints.");
212 }
213
214 const double ridge_lambda = 1-lasso_lambda;
215
216 if (num_nonnegative > num_dims)
217 num_nonnegative = num_dims;
218
219 typedef typename matrix_type::type scalar_type;
220 typedef typename matrix_type::layout_type layout_type;
221 typedef typename matrix_type::mem_manager_type mem_manager_type;
222 typedef matrix_type vect_type;
223
224 const scalar_type C = problem.get_c();
225
226 typename sequence<vect_type>::kernel_2a planes;
227 std::vector<scalar_type> bs, miss_count;
228
229 vect_type new_plane, alpha, btemp;
230
231 w.set_size(num_dims, 1);
232 w = 0;
233
234 // The current objective value. Note also that w always contains
235 // the current solution.
236 scalar_type cur_obj = std::numeric_limits<scalar_type>::max();
237
238 // This will hold the cutting plane objective value. This value is

Callers

nothing calls this directly

Calls 15

ones_matrixFunction · 0.85
zeros_matrixFunction · 0.85
set_rowmFunction · 0.85
join_colsFunction · 0.85
absFunction · 0.85
set_submFunction · 0.85
set_colmFunction · 0.85
solve_qp4_using_smoFunction · 0.85
solve_qp_using_smoFunction · 0.85
lowerboundFunction · 0.85
index_of_maxFunction · 0.85
removercFunction · 0.85

Tested by

no test coverage detected