how can I get the variable vector form a constraint

37 views
Skip to first unread message

覃岭

unread,
Mar 17, 2015, 10:52:06 AM3/17/15
to yal...@googlegroups.com
no matter how complicate the constraints is,such as:
const1=[
A*x1+B*x2 >= c,...
D*x1+E*x2 +F*x4 <=0,...
G*5 == h,...
];
we can always regard it as the standard form: Ax <= b
I know we can get A matrix by getbase function.
now I wonder how can I get the x and b vector from constr1?

Johan Löfberg

unread,
Mar 17, 2015, 10:54:47 AM3/17/15
to yal...@googlegroups.com
getbase gives you [b A] in the constraint b + A*x >= 0. recover(getvariables()) gives you the variables
Message has been deleted

覃岭

unread,
Mar 17, 2015, 7:23:07 PM3/17/15
to yal...@googlegroups.com
thanks, johan.
 recover(getvariables(x1))  can only get one vector.
I wonder how can I get the whole variable vector of the constraint, if the constraint contains x1, x2 and more other variable vectors just like:
const1=[
A*x1+B*x2 >= c,...
D*x1+E*x2 +F*x3 <=0,...
G*x4 == h,...
]
where x1,...,x4 are all variable vectors.

Johan Löfberg

unread,
Mar 18, 2015, 2:24:30 AM3/18/15
to yal...@googlegroups.com
recover(getvariables(const1))

gives you a vector with all constraints in const1 such that const1 is getbase(const1)*[1;x] >= (==) 0

覃岭

unread,
Mar 18, 2015, 7:51:28 AM3/18/15
to yal...@googlegroups.com
thanks!
Reply all
Reply to author
Forward
0 new messages