# Error Handling with LinearProgramming and Aborting subsequent evaluations

I am using a inbuilt LinearProgramming solver to perform an optimization. It is essentially solving a matrix equation and searching for a solution that maximizes a given function. However, when the matrix equation itself has no solutions, i.e, the system is inconsistent, the LinearProgramming method displays a message.

The output in this case is the input itself. For a concrete example, see here:

When there is a solution:

In[291]:= exCons={{0,0},{1,0},{-4,1},{6,-2},{0,1},{-3,0},{0,0},{1,0},{-4,1},{6,1},{12,-5},{-15,3}};
exSynd={-1,0,15,-30,0,0,-1,0,15,-15,-90,27};
In[293]:= dimCheck[exCons,exSynd]
Out[293]= {{0,15,0},False}


This case is ok, as I could use the vector output in subsequent calculations. However, when the system of equations is inconsistent, we have:

In[308]:= exCons={{0},{1},{-4},{6},{0},{-3},{0},{1},{-4},{6},{12},{-15}};
exSynd={-1,0,10,-20,-5,0,-1,0,10,-20,-65,12};
In[310]:= dimCheck[exCons,exSynd]
During evaluation of In[310]:= LinearProgramming::lpsnf: No solution can be found that satisfies the constraints. >>
Out[310]= {LinearProgramming[{0,1},{{0,-1},{1,-1},{-4,-1},{6,-1},{0,-1},{-3,-1},{0,-1},{1,-1},{-4,-1},{6,-1},{12,-1},{-15,-1}},{-1,0,10,-20,-5,0,-1,0,10,-20,-65,12},Automatic],False}


However, I am having to use the result of LinearProgramming in subsequent operations. Hence when there is no solution, I wish to exit out of the program, by calling Quit[] or Exit[]. The output of this above function is not really a list of numbers. I would like to tell mathematica that when the output is not a list, as above, the evaluation of the notebook must Abort.

Hope my question was clear.

-
Something like this. result = dimCheck[exCons,exSynd]; If[Head[result[[1]]]===LinearProgramming, Throw[\$Failed]];. And don't forget to wrap Catch[] around the caller. –  Daniel Lichtblau Mar 27 at 19:07