linineq.tst 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. % Examples taken from G.B. Dantzig.
  2. lll := {x1 >= 0,
  3. x1+2x2 <= 6,
  4. x1 + x2 >= 2,
  5. x1 - x2 >= 3,
  6. x2 >= 0,
  7. -2 x1 -x2 <= z };
  8. sol := linineq(lll,{x1,x2,z=min});
  9. sol := linineq(lll,{x1,x2,z=min},record=t);
  10. linineq({z = x1 + 2 x2 + 3 x3 + 4 x4,
  11. 4 = x1 + x2 + x3 + x4,
  12. -2 = x1 - 2 x2 + 3 x3 - 4 x4,
  13. x1>=0, x2>=0, x3>=0,x4>=0}, {z=min});
  14. linineq({z = x1 + 2 x2 + 3 x3 + 4 x4,
  15. 4 = x1 + x2 + x3 + x4,
  16. -2 = x1 - 2 x2 + 3 x3 - 4 x4,
  17. x1>=0, x2>=0, x3>=0,x4>=0}, {z=max});
  18. linineq({ x1 + x2 >= 1,
  19. x1 + x2 <= 2,
  20. x1 - x2 <= 1,
  21. x1 - x2 >=-1,
  22. -x2 =z } , {z=min});
  23. linineq({ 5x1 - 4x2 + 13x3 - 2x4 + x5 = 20,
  24. x1 - x2 + 5x3 - x4 + x5 = 8,
  25. x1 + 6x2 - 7x3 + x4 + 5x5 = z,
  26. x1>=0,x2>=0,x3>=0,x4>=0,x5>=0}, {z=min});
  27. % Examples for integer and mixed integer linear programming
  28. % (Beightler, Phillips, Wilde, pp. 142 ff)
  29. linineq({z= 3x1 + 2x2,
  30. 5x1 + 4x2 <= 23.7,
  31. x1 >= 0,
  32. x2 >= 0},
  33. {z=max},
  34. int={x1,x2});
  35. linineq({z= x1 + x2,
  36. -2x1 + 5x2 <= 8,
  37. 6x1 + x2 <= 30,
  38. x1 >= 0,
  39. x2 >= 0},
  40. {z=max},
  41. int={x1,x2});
  42. linineq({z=-7x1 + 106x2,
  43. -x1 + 15x2 <= 90,
  44. x1 + 2x2 <= 35,
  45. -3x1 + 4x2 <= 12,
  46. x1 >= 0,
  47. x2 >= 0},
  48. {z=max},
  49. int={x1,x2});
  50. linineq({z=9x1 + 6x2 + 5x3,
  51. 2x1 + 3x2 + 7x3 <= 35/2,
  52. 4x1 + 9x3 <= 15,
  53. x1 >= 0,
  54. x2 >= 0,
  55. x3 >= 0},
  56. {z=max},
  57. int={x1});
  58. % a case where the extremum requirement cannot be resolved
  59. sol := linineq(lll,{x1,x2,z=max});
  60. % print the selection from the intervals:
  61. on prlinineq;
  62. sol := linineq(lll,{x1,x2,z=min});
  63. sol := linineq(lll,{x1,x2,z=max});
  64. % print the full elimination process
  65. on trlinineq;
  66. sol := linineq(lll,{x1,x2,z=min});
  67. end;