@@ -81,19 +81,23 @@ def expand_ndarray(self, array_, expected_rows, expected_cols, fallback):
8181 return array_
8282
8383 # Setup the problem data and solver options
84- def setup (self , A , B , Q , R , N , rho = 1.0 , fdyn = None , verbose = False , ** settings ):
84+ def setup (self , A , B , Q , R , N , rho = 1.0 , fdyn = None ,
85+ x_min = None , x_max = None , u_min = None , u_max = None ,
86+ cone_constraints = None , verbose = False , ** settings ):
8587 """Instantiate necessary algorithm variables and parameters
8688
8789 :param A (np.ndarray): State transition matrix of the linear system, size nx x nx
8890 :param B (np.ndarray): Input matrix of the linear system, size nx x nu
8991 :param Q (np.ndarray): Stage cost for state, must be diagonal and positive semi-definite, size nx x nx
9092 :param R (np.ndarray): Stage cost for input, must be diagonal and positive definite, size nu x nu
93+ :param N (int): Prediction horizon length
9194 :param rho (float, optional): Penalty term used in ADMM, default 1.0
9295 :param fdyn (np.ndarray or None, optional): Affine offset vector for dynamics, size nx x 1. If None, defaults to zeros (linear system), default None
93- :param x_min (list[float] or None, optional): Lower bound state constraints of the same length as nx, default None
94- :param x_max (list[float] or None, optional): Upper bound state constraints of the same length as nx, default None
95- :param u_min (list[float] or None, optional): Lower bound input constraints of the same length as nu, default None
96- :param u_max (list[float] or None, optional): Upper bound input constraints of the same length as nu, default None
96+ :param x_min (np.ndarray or None, optional): Lower bound state constraints, size nx or nx x N, default None
97+ :param x_max (np.ndarray or None, optional): Upper bound state constraints, size nx or nx x N, default None
98+ :param u_min (np.ndarray or None, optional): Lower bound input constraints, size nu or nu x (N-1), default None
99+ :param u_max (np.ndarray or None, optional): Upper bound input constraints, size nu or nu x (N-1), default None
100+ :param cone_constraints (dict or None, optional): Cone constraints dict with keys {Acu, qcu, cu, Acx, qcx, cx}, default None
97101 :param verbose (bool): Whether or not to print data to console during setup, default False
98102 :params settings: Dictionary of optional settings
99103 :param abs_pri_tol (float): Solution tolerance for primal variables
@@ -155,6 +159,14 @@ def setup(self, A, B, Q, R, N, rho=1.0, fdyn=None, verbose=False, **settings):
155159 self .nx , self .nu , self .N ,
156160 self .settings , self .verbose )
157161
162+ # Handle constraints if provided
163+ if any (x is not None for x in [x_min , x_max , u_min , u_max ]):
164+ self .set_bound_constraints (x_min , x_max , u_min , u_max )
165+
166+ if cone_constraints is not None :
167+ # cone_constraints should be a dict with keys: Acu, qcu, cu, Acx, qcx, cx
168+ self .set_cone_constraints (** cone_constraints )
169+
158170 def set_x0 (self , x0 ):
159171 assert len (x0 .shape ) == 1
160172 assert len (x0 ) == self .nx
0 commit comments