PyDiffGame 0.1.2__py3-none-any.whl → 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PyDiffGame/__init__.py +50 -0
- PyDiffGame/_typing.py +25 -0
- PyDiffGame/base.py +468 -0
- PyDiffGame/comparison.py +121 -0
- PyDiffGame/continuous.py +223 -0
- PyDiffGame/discrete.py +211 -0
- PyDiffGame/examples/InvertedPendulumComparison.py +211 -236
- PyDiffGame/examples/MassesWithSpringsComparison.py +109 -208
- PyDiffGame/examples/PVTOL.py +143 -149
- PyDiffGame/examples/PVTOLComparison.py +75 -69
- PyDiffGame/examples/QuadRotorControl.py +394 -304
- PyDiffGame/lqr.py +30 -0
- PyDiffGame/objective.py +108 -0
- PyDiffGame/plotting.py +98 -0
- pydiffgame-2.0.0.dist-info/METADATA +408 -0
- {pydiffgame-0.1.2.dist-info → pydiffgame-2.0.0.dist-info}/RECORD +18 -16
- {pydiffgame-0.1.2.dist-info → pydiffgame-2.0.0.dist-info}/WHEEL +1 -1
- PyDiffGame/ContinuousPyDiffGame.py +0 -275
- PyDiffGame/DiscretePyDiffGame.py +0 -359
- PyDiffGame/LQR.py +0 -73
- PyDiffGame/Objective.py +0 -62
- PyDiffGame/PyDiffGame.py +0 -1273
- PyDiffGame/PyDiffGameLQRComparison.py +0 -169
- pydiffgame-0.1.2.dist-info/METADATA +0 -306
- {pydiffgame-0.1.2.dist-info → pydiffgame-2.0.0.dist-info}/licenses/LICENSE +0 -0
PyDiffGame/LQR.py
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
from typing import Sequence, Optional
|
|
3
|
-
from abc import ABC
|
|
4
|
-
|
|
5
|
-
from PyDiffGame.PyDiffGame import PyDiffGame
|
|
6
|
-
from PyDiffGame.ContinuousPyDiffGame import ContinuousPyDiffGame
|
|
7
|
-
from PyDiffGame.DiscretePyDiffGame import DiscretePyDiffGame
|
|
8
|
-
from PyDiffGame.Objective import LQRObjective
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class LQR(PyDiffGame, ABC):
|
|
12
|
-
"""
|
|
13
|
-
LQR abstract base class
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Considers a differential game with only one objective
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
def __init__(self,
|
|
20
|
-
A: np.array,
|
|
21
|
-
B: np.array,
|
|
22
|
-
objective: LQRObjective,
|
|
23
|
-
x_0: Optional[np.array] = None,
|
|
24
|
-
x_T: Optional[np.array] = None,
|
|
25
|
-
T_f: Optional[float] = None,
|
|
26
|
-
P_f: Optional[np.array] = None,
|
|
27
|
-
show_legend: Optional[bool] = True,
|
|
28
|
-
state_variables_names: Optional[Sequence[str]] = None,
|
|
29
|
-
epsilon_x: Optional[float] = PyDiffGame._epsilon_x_default,
|
|
30
|
-
L: Optional[int] = PyDiffGame._L_default,
|
|
31
|
-
eta: Optional[int] = PyDiffGame._eta_default,
|
|
32
|
-
debug: Optional[bool] = False):
|
|
33
|
-
super().__init__(A=A,
|
|
34
|
-
B=B,
|
|
35
|
-
objectives=[objective],
|
|
36
|
-
x_0=x_0,
|
|
37
|
-
x_T=x_T,
|
|
38
|
-
T_f=T_f,
|
|
39
|
-
P_f=P_f,
|
|
40
|
-
show_legend=show_legend,
|
|
41
|
-
state_variables_names=state_variables_names,
|
|
42
|
-
epsilon_x=epsilon_x,
|
|
43
|
-
L=L,
|
|
44
|
-
eta=eta,
|
|
45
|
-
debug=debug)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
class ContinuousLQR(LQR, ContinuousPyDiffGame):
|
|
49
|
-
"""
|
|
50
|
-
Continuous LQR marker class
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Considers control design according to the system:
|
|
54
|
-
dx(t)/dt = A x(t) + B u(t)
|
|
55
|
-
"""
|
|
56
|
-
|
|
57
|
-
pass
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
class DiscreteLQR(LQR, DiscretePyDiffGame):
|
|
61
|
-
"""
|
|
62
|
-
Discrete LQR marker class
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
Considers control design according to the system:
|
|
66
|
-
x[k+1] = A_tilda x[k] + B_tilda u[k]
|
|
67
|
-
|
|
68
|
-
where A_tilda and B_tilda are in discrete form, meaning they correlate to a discrete system,
|
|
69
|
-
which, at the sampling points, is assumed to be equal to some equivalent continuous system of the form:
|
|
70
|
-
dx(t)/dt = A x(t) + B u(t)
|
|
71
|
-
"""
|
|
72
|
-
|
|
73
|
-
pass
|
PyDiffGame/Objective.py
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
from abc import ABC
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Objective(ABC):
|
|
6
|
-
"""
|
|
7
|
-
Objective abstract base class
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Parameters
|
|
11
|
-
----------
|
|
12
|
-
Q: 2-d np.array of shape(n, n)
|
|
13
|
-
Cost function state weights for the objective
|
|
14
|
-
R_ii: 2-d np.array of shape(m_i, m_i)
|
|
15
|
-
Cost function input weights for the objective with regard to the i'th input
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
def __init__(self,
|
|
19
|
-
Q: np.array,
|
|
20
|
-
R_ii: np.array):
|
|
21
|
-
self._Q = Q
|
|
22
|
-
self._R_ii = R_ii
|
|
23
|
-
|
|
24
|
-
@property
|
|
25
|
-
def Q(self) -> np.array:
|
|
26
|
-
return self._Q
|
|
27
|
-
|
|
28
|
-
@property
|
|
29
|
-
def R(self) -> np.array:
|
|
30
|
-
return self._R_ii
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class LQRObjective(Objective):
|
|
34
|
-
"""
|
|
35
|
-
LQR objective marker class
|
|
36
|
-
"""
|
|
37
|
-
|
|
38
|
-
pass
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
class GameObjective(Objective):
|
|
42
|
-
"""
|
|
43
|
-
Game objective class
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
Parameters
|
|
47
|
-
----------
|
|
48
|
-
M_i: 2-d np.array of shape(m_i, m)
|
|
49
|
-
Division matrix for the i'th virtual input
|
|
50
|
-
"""
|
|
51
|
-
|
|
52
|
-
def __init__(self,
|
|
53
|
-
Q: np.array,
|
|
54
|
-
R_ii: np.array,
|
|
55
|
-
M_i: np.array):
|
|
56
|
-
self.__M_i = M_i
|
|
57
|
-
super().__init__(Q=Q,
|
|
58
|
-
R_ii=R_ii)
|
|
59
|
-
|
|
60
|
-
@property
|
|
61
|
-
def M_i(self) -> np.array:
|
|
62
|
-
return self.__M_i
|