solve() behaving unexpectedly with multiple inequalities

조회 수: 3 (최근 30일)
Jonathan Keegan
Jonathan Keegan 2021년 7월 31일
댓글: Jonathan Keegan 2021년 7월 31일
I'm encountering strange behavior with what should be straightforward calculations using solve(). I've been experimenting with this a bit to try and see if I can explain it, but I'm coming up with nothing. I'm stumped as to what's going on - the below image encapsulating a minimal working example is what made me give up and resort to asking here:
As you can see here, the ability of solve() to find a solution appears to depend on the names of the variables. Or at least, I think that's what's going on.
Below is a similar example of strange behavior demonstrating that solve() is, in fact, able to handle this when the parameters are handled in separate calls:
Am I doing something wrong here? Is MATLAB interpreting my input in an unintended fashion that is leading to this behavior?
  댓글 수: 2
Cris LaPierre
Cris LaPierre 2021년 7월 31일
It doesn't have to do with the variables used. I get the same behavior if I use a and b.
It seems to have something to do with the alphabetical order in which the variables are solved for.
syms a b
S1=solve([0>=b 0<=b a>=0],[a b])
S1 = struct with fields:
a: [0×1 sym] b: [0×1 sym]
S2=solve([0>=b 0<=b a>=0],[b a])
S2 = struct with fields:
b: [1×1 sym] a: [1×1 sym]
I know this is not an answer (hence why I'm adding it as a comment). As for why, I don't know. Perhaps some insight can be gained through this example. Note that, when it does yield a solution, it does so under conditions. Those can be viewed using the 'ReturnConditions',true input.
S3=solve([0>=b 0<=b a>=0],[b a],'ReturnConditions',true)
S3 = struct with fields:
b: [1×1 sym] a: [1×1 sym] parameters: [1×1 sym] conditions: [1×1 sym]
S3.parameters
ans = 
x
S3.conditions
ans = 
Jonathan Keegan
Jonathan Keegan 2021년 7월 31일
Do you have any suggestions for how to use MATLAB to solve systems of inequalities? Are there any reductions I can use so that MATLAB isn't so... obviously wrong? I am working with integer-valued variables so there might be something else, but I'm not well versed enough in optimization theory to do anything with convex hulls or high dimensional polytopes to make something that works well myself. I'd like to enumerate all solutions instead of simply getting one (like I could do with intlinprog) and.. usually solve() works alright for this, but I'm losing confidence in its abilities.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by