Advertisement
varli_ketanpl

aplicatie 2 lab9

May 4th, 2023
1,050
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.99 KB | None | 0 0
  1. using JuMP
  2. using HiGHS
  3.  
  4. Scaune = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]
  5. C = length(Scaune)
  6. LiniiProductie = [1, 2, 3, 4, 5]
  7. P = length(LiniiProductie)
  8.  
  9. Profit = [6, 5, 9, 5, 6, 3, 4, 7, 4, 3]
  10. Capacitate = [47, 19, 36, 13, 46]
  11. ResurseFolosite = [
  12.     6 4 2 3 1 10 2 9 3 5;
  13.     5 6 1 1 7 2 9 1 8 6;
  14.     8 10 7 2 9 6 9 6 5 6;
  15.     8 4 8 10 5 4 1 5 3 5;
  16.     1 4 7 2 4 1 2 3 10 1;
  17. ]
  18.  
  19. IC2 = Model(HiGHS.Optimizer)
  20.  
  21. @variable(IC2, x[c=1:C]>=0)
  22.  
  23. @objective(IC2, Max, sum(Profit[c]*x[c] for c=1:C))
  24.  
  25. @constraint(IC2, [p=1:P],
  26. sum(ResurseFolosite[p, c]*x[c] for c=1:C) <= Capacitate[p])
  27.  
  28. optimize!(IC2)
  29. println("Status final: $(termination_status(IC2))")
  30.  
  31. if termination_status(IC2) == MOI.OPTIMAL
  32.     println("Valoarea functiei obiectiv: \$(objective_value(IC2))")
  33.     for c = 1:C
  34.         if value(x[c]) > 0.001
  35.             println("Scaun de tip: ", Scaune[c], " a fost produs in cantitatea: ", value(x[c]))
  36.         end
  37.     end
  38. else
  39.     println("Nici o solutie gasita")
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement