Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have been trying to figure out how to solve a system of inequalities relatively. I don't care about values, I just want all possible ordering. An example system might be:$${b > r,\; p > r,\; c - 1 = p,\; c < x,\; h > x,\; h < e, }$$ $${r < k,\; q > k,\; l - 1 = q,\; l < h,\; k > p}$$

I want to get all possible ways they could be arranged in order, satisfying the inequalities. If I am not explaining this well, please let me know, I'm not sure how to describe what I'm looking in a more mathematical way.

Is there a straightforward way to do it? I tried using Reduce over the domain of Integers, but it choked. FindInstance was able to find a single instance, but not more than that.

Edit: I tried:

FindInstance[{ b > r, p > r, c - 1 == p, c < x, h > x, h < e, 
               r < k, q > k, l - 1 == q, l < h, k > p}, 
             { b, r, p, c, x, h, e, k, q, l}]
{{b -> 0, r -> -1, p -> 0, c -> 1, x -> 2, h -> 3, e -> 4, k -> 1/2, q -> 1, l -> 2}}

This is basically what I'm looking for, but when I tried increasing n, I let it run for 5+ minutes and never got a solution.

I also tried:

Reduce[{ b > r, p > r, c - 1 == p, c < x, h > x, h < e, 
         r < k, q > k, l - 1 == q, l < h, k > p}, 
       {b, r, p, c, x, h, e, k, q, l}]
 b ∈ Reals && r < b && p > r && c == 1 + p && x > 1 + p && h > x && 
 e > h && p < k < -1 + h && k < q < -1 + h && l == 1 + q

when I tried Reduce over the domain Integers, the output was several hundred lines long.

Edit : Sorting by the second element, the revised version is:

 DeleteDuplicates[
   Map[ First, Map[ SortBy[ #, Last] &, 
                    FindInstance[{ b > r, p > r, c - 1 == p, c < x, h > x, h < e, r < k, 
                                   q > k, l - 1 == q, l < h, k > p}, 
                                   { b, r, p, c, x, h, e, k, q, l}, 10]
                  ], {2}]]
share|improve this question
    
Please share your Reduce[] and FindInstance[] codes with us –  belisarius Nov 21 '13 at 1:56
    
@belisarius just added –  kyryx Nov 21 '13 at 2:00
1  
Re:your Edit. Your Map[First, ...] is getting the name of the variables only ... and they (the names) are always the same (of course). I don't get your point –  belisarius Nov 21 '13 at 2:29
    
@belisarius You're correct, I meant to sort by the second element. I posted a corrected version. I appreciate the help. –  kyryx Nov 21 '13 at 2:42

1 Answer 1

up vote 3 down vote accepted

Try for example:

FindInstance[{b > r, p > r, c - 1 == p, c < x, h > x, h < e, r < k, 
             q > k, l - 1 == q, l < h, k > p}, {b, r, p, c, x, h, e, k, q, l}, 15]

which gives you 15 different solutions

share|improve this answer
    
Very odd, I just realized when I was trying it, I specified the domain Integers, which never gave a solution. But without integers, it does it instantly.. –  kyryx Nov 21 '13 at 2:13
    
I actually am not sure that works. I don't think those solutions are unique. See my edit above. –  kyryx Nov 21 '13 at 2:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.