0

Using MuPAD, I want to find out if at least one solution exists for a set of of linear inequalities. For example, the following system of linear inequalities:

enter image description here

which I solve in MuPAD by:

solve({x+z>2*y,z>y,2*z>2*x,x>0,y>0,z>0},{x,y,z}

and MuPAD returns the set of solutions, in some type of notation:

enter image description here

However, I do not care about the exact form of the solution set, i.e., whether it is finite, or infinite, I just care if there is at least one viable solution.

I would like to call MuPAD from Matlab, ask if a solution set exists to the inequalities, and then get back a "yes" or "no" answer. I could test for the empty set being returned, but I do not know how to test if a symbolic variable represents the empty set.

edison1093
  • 23
  • 6
  • 2
    Can you provide a simple example – in Matlab or MuPAD code – with cases that meet these two conditions (one or more solutions and no solutions)? We can't really help if you don't at least show the code/functions you're using. – horchler Mar 19 '14 at 17:05

1 Answers1

0

Here's an example using MuPAD's solve and sym/isempty called from Matlab:

syms x y z;
~isempty(feval(symengine,'solve',[x+z>2*y,z>y,2*z>2*x,x>0,y>0,z>0],[x y z]))
~isempty(feval(symengine,'solve',[x+z>2*y,z>y,2*z>2*x,x>0,y>0,z<0],[x y z]))

The first case returns true, 1, indicating that there is at least one solution. The second returns false, 0, as there is no solution.

If you want to do this within MuPAD, you can use the is function:

not(is(solve([x+z>2*y,z>y,2*z>2*x,x>0,y>0,z>0],[x,y,z])={}))
not(is(solve([x+z>2*y,z>y,2*z>2*x,x>0,y>0,z<0],[x,y,z])={}))

However, the first case will return UNKNOWN, which is rather difficult to deal with. You may want to use something like the following instead:

is(length(solve([x+z>2*y,z>y,2*z>2*x,x>0,y>0,z>0],[x,y,z]))>1)
is(length(solve([x+z>2*y,z>y,2*z>2*x,x>0,y>0,z<0],[x,y,z]))>1)

which assumes that only an empty solution, Ø, will have a length of one. (The MuPAD code is two characters, {}, but it displays as one, Ø, has a length of one, and means empty/zero.) There are probably other ways.

horchler
  • 18,384
  • 4
  • 37
  • 73
  • Thanks for your help horchler, using `length` seems to work acceptably. On another note, rather disconcertingly, MuPad reports solutions exist for the following inequality set: `solve({(2*y)>(x+z),x>y,z>x,x>0,y>0,z>0},{x,y,z})`, where by my logic there can be none! – edison1093 Mar 20 '14 at 20:29
  • @edison1093: Glad to help. I'm not particularly familiar with systems of inequalities. You might try a simple plot (using `plot3` in Matlab or something in MuPAD) of the regions of interest. Just split the planes/surfaces of equality to begin with, i.e, `(2*y)=(x+z)`,`x=y`,`z=x`, over some range of `x`, `y`, and `z` starting from zero. – horchler Mar 21 '14 at 01:57