Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. !@encoding CP1252
  2. model ModelName
  3. uses "mmxprs"; !gain access to the Xpress-Optimizer solver
  4.  
  5.  
  6. !sample declarations section
  7. declarations
  8.  
  9. I = 1..7
  10.  
  11. p:array(I) of integer
  12. m:array(I,I) of integer
  13. a:array(I,I) of integer
  14. u:array(I,I) of integer
  15.  
  16. pre:array(I,I) of mpvar
  17. x:array(I) of mpvar
  18.  
  19.  
  20. FO:linctr
  21. end-declarations
  22.  
  23. p::[10000,10000,10000,4000,4000,4000,4000]
  24. m::[0,0,0,1,0,0,1,
  25. 0,0,0,0,0,1,0,
  26. 0,0,0,1,0,0,0,
  27. 1,0,1,0,0,1,1,
  28. 0,0,0,0,0,1,1,
  29. 0,1,0,1,1,0,0,
  30. 1,0,0,1,1,0,0]
  31.  
  32. a::[0,0,0,0,0,0,0,
  33. 0,0,0,1,1,0,0,
  34. 0,0,0,0,0,0,0,
  35. 0,1,0,0,1,0,0,
  36. 0,1,0,1,0,0,0,
  37. 0,0,0,0,0,0,0,
  38. 0,0,0,0,0,0,0]
  39.  
  40.  
  41. u::[0,1,1,0,0,0,0,
  42. 0,0,0,0,0,0,0,
  43. 0,0,0,0,0,0,0,
  44. 0,0,0,0,0,0,0,
  45. 0,0,0,0,0,0,0,
  46. 0,0,0,0,0,0,0,
  47. 0,0,0,0,0,0,0]
  48.  
  49. FO:= sum(i in I)(p(i)*x(i)) + 0.1*(sum(i in I, j in I)(p(i)*pre(i,j)*a(i,j))) - 0.3*(sum(i in I, j in I)(p(i)*pre(i,j)*m(i,j)))
  50.  
  51. forall(i in I) x(i) is_binary
  52. forall(i in I, j in I) pre(i,j) is_binary
  53.  
  54. forall(i in I, j in I) x(j) <= (1-x(i)*u(i,j))
  55.  
  56. forall(i in I, j in I) x(i) + x(j) - 1 <= pre(i,j)
  57. forall(i in I, j in I) x(i) + x(j) >= 2*pre(i,j)
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. writeln("Begin running model")
  66. maximize(FO)
  67. writeln("End running model")
  68. writeln("Profitto massimo: ", getobjval)
  69. forall(i in I) writeln("x(i) = ",getsol(x(i)))
  70.  
  71.  
  72. end-model
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement