-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Including formulas for Alpha and Beta #28
Conversation
@@ -111,8 +111,8 @@ | |||
vars.Q = -diag(Q); | |||
vars.R = -diag(R); | |||
end | |||
vars.UB = UB; | |||
vars.LB = LB; | |||
% vars.UB = UB; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't comment this line. Having it in the vars
variable is useful. In your code right now it is not used, but it will probably be used for default values of the bounds. I would add UB
and LB
back to the vars
structure.
@@ -91,8 +91,8 @@ | |||
vars.R = -diag(R); | |||
vars.QRi = -[1./diag(Q); 1./diag(R)]; | |||
end | |||
vars.UB = UB; | |||
vars.LB = LB; | |||
% vars.UB = UB; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Add UB
and LB
back to vars
.
@@ -116,6 +116,7 @@ | |||
constCell = add_line(constCell, 'Alpha', vars.Alpha, 1, precision, var_options); | |||
constCell = add_line(constCell, 'Beta', vars.Beta, 1, precision, var_options); | |||
end | |||
constCell = add_line(constCell, 'dummy', 5, 1, precision, var_options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I imagine the point of this dummy
variable is to have at least one variable in consCell
, because if it is empty then its associated flag is never deleted, so you get a compilation-time error.
Is this correct? If it is, then we can leave it for now and I will create an Issue to work on solving this bug (because we want to avoid having a dummy
variable in our code....).
% constCell = add_line(constCell, 'UB0', vars.UB(n+1:end, 1), 1, precision, var_options); | ||
% constCell = add_line(constCell, 'LB', vars.LB(:, 2:end)', 1, precision, var_options); | ||
% constCell = add_line(constCell, 'UB', vars.UB(:, 2:end)', 1, precision, var_options); | ||
% defCell = add_line(defCell, 'VAR_BOUNDS', 1, 1, 'int', 'define'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your changes have disabled the option of having different bounds for each prediction step, which was determined before by the VAR_BOUNDS
variable. I'll have to include this option back in the future, since it is useful for robust MPC, for example. I will see how it can be done at the same time as letting the user modify the bounds online.
@@ -19,6 +19,8 @@ void mexFunction(int nlhs, mxArray *plhs[], | |||
double *Q; | |||
double *R; | |||
#endif | |||
double *LB; // Local LB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will want to make these optional inputs, so that the user can call the solver as solver(x, xr, ur);
, instead of having to do it as solver(x, xr, ur, [LBx ; LBu], [UBx ; UBu]);
. The default values will be taken from the system model passed to the toolbox when generating the solver.
Also, it might be better to change it so that the function is called like solver(x, xr, ur, LBx, UBx, LBu, UBu);
, or maybe some structure, i.e., solver(x, xr, ur, constraints);
, where constraints
is a struct containing the fields LBx
, UBx
, LBu
and UBu
.
@@ -117,8 +117,8 @@ | |||
else | |||
vars.T_rho_i = inv(T+rho*eye(n)); | |||
end | |||
vars.UB = UB; | |||
vars.LB = LB; | |||
% vars.UB = UB; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment. Put UB
and LB
back into vars
.
@@ -97,8 +97,8 @@ | |||
vars.QRi = -[1./diag(Q); 1./diag(R)]; | |||
end | |||
|
|||
vars.UB = UB; | |||
vars.LB = LB; | |||
% vars.UB = UB; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment. Put UB
and LB
back into vars
.
} | ||
#endif | ||
#if in_engineering == 0 | ||
for(unsigned int i = 0; i < nn; i++){ | ||
x0[i] = pointer_x0[i]; | ||
xr[i] = pointer_xr[i]; | ||
LB[i] = pointer_LB[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 129-130
can be merged with lines 134-135
into a single for
loop. The only reason to have them separate would be if we had LBx
, UBx
, LBu
, UBu
as separate inputs in the C function.
No description provided.