| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// Rapid Optimization Library (ROL) Package |
| 4 |
// |
| 5 |
// Copyright 2014 NTESS and the ROL contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#pragma once |
| 11 |
#ifndef L1_OPTIMIZATION_PROBLEM_HPP |
| 12 |
#define L1_OPTIMIZATION_PROBLEM_HPP |
| 13 |
|
| 14 |
#include "ROL_Bounds.hpp" |
| 15 |
#include "ROL_BoundConstraint_Partitioned.hpp" |
| 16 |
#include "ROL_OptimizationProblem.hpp" |
| 17 |
#include "l1_penalty_objective.hpp" |
| 18 |
#include "l1_penalty_constraint.hpp" |
| 19 |
#include "identity_constraint.hpp" |
| 20 |
|
| 21 |
namespace ROL { |
| 22 |
|
| 23 |
template<typename Real> |
| 24 |
Ptr<OptimizationProblem<Real>> |
| 25 |
make_l1_penalty_problem( const Ptr<Objective<Real>>& obj, |
| 26 |
const Ptr<Vector<Real>>& x, |
| 27 |
const Ptr<Constraint<Real>>& con, |
| 28 |
const Ptr<Vector<Real>>& emul, |
| 29 |
Real gamma ) { |
| 30 |
auto r = emul->clone(); |
| 31 |
auto s = emul->clone(); |
| 32 |
auto lb = emul->clone(); |
| 33 |
auto ub = emul->clone(); |
| 34 |
|
| 35 |
r->setScalar(1.0); |
| 36 |
s->setScalar(1.0); |
| 37 |
lb->zero(); |
| 38 |
ub->setScalar(ROL_INF<Real>()); |
| 39 |
|
| 40 |
std::vector<Ptr<Vector<Real>>> xrs = {x,r,s}; |
| 41 |
auto xp = makePtr<PartitionedVector<Real>>( xrs ); |
| 42 |
|
| 43 |
auto x_bnd = makePtr<BoundConstraint<Real>>(*x); |
| 44 |
auto rs_bnd = makePtr<Bounds<Real>>(lb,ub); |
| 45 |
|
| 46 |
x_bnd->deactivate(); |
| 47 |
rs_bnd->activateLower(); |
| 48 |
rs_bnd->deactivateUpper(); |
| 49 |
|
| 50 |
auto bnds = std::vector<Ptr<BoundConstraint<Real>>>{{x_bnd,rs_bnd,rs_bnd}}; |
| 51 |
auto bnd = makePtr<BoundConstraint_Partitioned<Real>>(bnds,xrs); |
| 52 |
|
| 53 |
auto lp_obj = makePtr<L1PenaltyObjective<Real>>(obj,*emul,gamma); |
| 54 |
auto lp_con = makePtr<L1PenaltyConstraint<Real>>(con); |
| 55 |
|
| 56 |
return makePtr<OptimizationProblem<Real>>(lp_obj,xp,bnd,lp_con,emul); |
| 57 |
} |
| 58 |
|
| 59 |
template<typename Real> |
| 60 |
Ptr<OptimizationProblem<Real>> |
| 61 |
make_l1_penalty_problem( const Ptr<Objective<Real>>& obj, |
| 62 |
const Ptr<Vector<Real>>& x, |
| 63 |
Real gamma ) { |
| 64 |
Ptr<Constraint<Real>> con = makePtr<IdentityConstraint<Real>>(); |
| 65 |
return make_l1_penalty_problem(obj,x,con,x,gamma); |
| 66 |
} |
| 67 |
|
| 68 |
} // namespace ROL |
| 69 |
|
| 70 |
|
| 71 |
#endif // L1_OPTIMIZATION_PROBLEM_HPP |
| 72 |
|