-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathconstraint.py
More file actions
43 lines (34 loc) · 1.02 KB
/
constraint.py
File metadata and controls
43 lines (34 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class Constraint:
def distance_squared(self, u):
"""
Squared distance of a given point to the set
:param u: given point
:return: squared distance
:rtype: float
"""
raise NotImplementedError(
"Method `distance_squared` is not implemented")
def project(self, u):
"""
Project a given point onto the set
:param u: given point
:return: projection of `u` onto this set
"""
raise NotImplementedError("Method `project` is not implemented")
def is_convex(self):
"""
Whether the set is convex
"""
return False
def is_compact(self):
"""
Whether the set is compact
"""
return False
def dimension(self):
"""
Constraint dimension
Derived classes can override this method to return the dimension of the
constraint, where possible, or return `None` if the constraint does not
have a fixed dimension.
"""