• API
• FAQ
• Tools
• Archive
daily pastebin goal
92%
SHARE
TWEET

# Untitled

a guest May 16th, 2018 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. %-------------------------------------
2. %------ PROGRAMOWANIE LINIOWE  -------
3. %-------------------------------------
4.
5. close all
6. clear all
7. clc
8.
9. f = [2, 1.5, 3];
10. A = [4, 6, 15; 2, 2, 0; 5, 3, 4; 7, 3, 12];
11. b = [250, 60, 100, 220];
12.
13. [X, fval] = linprog(f, -A, -b, [], [], 0, inf, []);
14. x = ceil(X);
15. fval;
16. x' * f';
17.
18. M = A * x;
19.
20.
21. f2 = [100, 200];
22. A2 = [5, 25; 0.5, 0; 100, 250; 10, 10];
23. b2 = [500, 15, 7500, 400];
24.
25. [X2, fval2] = linprog(-f2, A2, b2, [], [], 0, inf, []);
26. x2 = round(X2);
27. fval=-fval2;
28. M2 = A2 * x2;
29.
30. fprintf('Kanapki: %d, pierogi: %d, slodycze: %d\n', x(1), x(2), x(3));
31. fprintf('---Wartosci odzywcze-----\n');
32. fprintf('Bialko: %d, tluszcz: %d, witaminy: %d, weglowodany: %d\n', M(1), M(2), M(3), M(4));
33. cena = f*x;
34. fprintf('Koszt takiej diety wynosi: %f\n', cena)
35. fprintf('-------------------\n');
36. fprintf('Ilosc krzesel: %d, ilosc stolow: %d\n', x2(1), x2(2));
37. cena2 = f2*x2;
38. fprintf('Kosztem %d zysk bedzie najwiekszy\n', cena2);
39. fprintf('Drewno: %d, skora: %f, klej: %d, naklad pracy: %d', M2(1), M2(2), M2(3), M2(4));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.