File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ mutable struct ConvexLipschitzFunction <: AbstractFunction
2+ M:: Float64
3+ _PEPit_func:: PEPFunction
4+
5+ function ConvexLipschitzFunction (param; is_leaf= true , decomposition_dict= nothing , reuse_gradient= false )
6+ @assert is_leaf
7+ func = PEPFunction (is_leaf= is_leaf, decomposition_dict= decomposition_dict, reuse_gradient= reuse_gradient)
8+ M = float (param[" M" ])
9+ if M == Inf
10+ @warn " (PEPit) The class of convex M-Lipschitz functions with M == Inf implies no constraint: it contains all convex closed proper functions."
11+ end
12+ return new (M, func)
13+ end
14+ end
15+
16+
17+ gradient! (f:: ConvexLipschitzFunction , p:: Point ) = gradient! (f. _PEPit_func, p)
18+ value! (f:: ConvexLipschitzFunction , p:: Point ) = value! (f. _PEPit_func, p)
19+ stationary_point! (f:: ConvexLipschitzFunction ) = stationary_point! (f. _PEPit_func)
20+ add_constraint! (func:: ConvexLipschitzFunction , constraint:: Constraint ) = add_constraint! (func. _PEPit_func, constraint)
21+
22+ function add_class_constraints! (func:: ConvexLipschitzFunction )
23+ points_list = func. _PEPit_func. list_of_points
24+
25+ if func. M != Inf
26+ M2 = func. M^ 2
27+ for point_i in points_list
28+ _, gi, _ = point_i
29+ add_constraint! (func, gi^ 2 <= M2)
30+ end
31+ end
32+
33+ for point_i in points_list, point_j in points_list
34+ if point_i == point_j
35+ continue
36+ end
37+ xi, gi, fi = point_i
38+ xj, gj, fj = point_j
39+ add_constraint! (func, fi - fj >= gj * (xi - xj))
40+ end
41+ end
42+
43+ _get_pep_func (f:: ConvexLipschitzFunction ) = f. _PEPit_func
44+
45+
You can’t perform that action at this time.
0 commit comments