Guest User

Untitled

a guest
Oct 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. Clear[n, m, mFull, G, a, A1, A2, A3, A4, constraintsFull, reducedSystem];
  2. SeedRandom[13];
  3. n = 4;
  4. m = 6;
  5.  
  6. (* Full system *)
  7. mFull = {{0, a1[1, 2], a1[1, 3], a1[1, 4]}, {a2[2, 1], 0, a2[2, 3],
  8. a2[2, 4]}, {a3[3, 1], a3[3, 2], 0, a3[3, 4]}, {a4[4, 1], a4[4, 2],
  9. a4[4, 3], 0}};
  10.  
  11. (* constraints for individual elements in "mFull" *)
  12. constraintsFull = Table[{
  13. 0 <= a1[1, j] <= 1,
  14. 0 <= a2[2, j] <= 1,
  15. 0 <= a3[3, j] <= 1,
  16. 0 <= a4[4, j] <= 1}, {j, 1, n}]; (* for all j *)
  17.  
  18. (* define Upper Limits for "mFull" *)
  19. upperLimitFull = {
  20. {A1Full = Total[Ta[![enter image description here][1]][1]ble[a1[1, j], {j, 1, n}] /. a1[1, 1] -> 0]},
  21. {A2Full = Total[Table[a2[2, j], {j, 1, n}] /. a2[2, 2] -> 0]},
  22. {A3Full = Total[Table[a3[3, j], {j, 1, n}] /. a3[3, 3] -> 0]},
  23. {A4Full = Total[Table[a4[4, j], {j, 1, n}] /. a4[4, 4] -> 0]}
  24. };
  25.  
  26. (* For the reduced system *)
  27. G = RandomGraph[{n, m}, DirectedEdges -> True];
  28. reducedSystem = AdjacencyMatrix[G]*mFull;
  29.  
  30. constraintsReduced = {
  31. 0 <= a1[1, 4] <= 1,
  32. 0 <= a2[2, 1] <= 1,
  33. 0 <= a2[2, 3] <= 1,
  34. 0 <= a3[3, 2] <= 1,
  35. 0 <= a4[4, 1] <= 1,
  36. 0 <= a4[4, 3] <= 1
  37. };
  38.  
  39. (* define Upper Limits for "reducedSystem" *)
  40. upperLimitReduced = {
  41. {A1reduced = reducedSystem[[1]] // Total},
  42. {A2reduced = reducedSystem[[2]] // Total},
  43. {A3reduced = reducedSystem[[3]] // Total},
  44. {A4reduced = reducedSystem[[4]] // Total}
  45. };
Add Comment
Please, Sign In to add comment