% Coefficients for the cost function (cost per ton of each ore)
f = [27; 25; 32; 22; 20; 24];
% Inequality for impurities (impurity limit constraint)
A_ineq = [40 15 30 50 35 29];
% Maximum impurity level (example)
b_ineq = 50; % Set to your impurity limit
% Total ton constraint (equality)
Aeq = [1 1 1 1 1 1];
beq = 1;
% Metal content requirements
A = [-19 -43 -17 -20 0 -12;
-15 -10 0 -12 -24 -18;
-12 -25 0 0 -10 -16;
-14 -7 -53 -18 -31 -25];
% Metal requirement bounds (example; adjust to specific needs)
lb = zeros(6,1); % Lower bounds: non-negative values
ub = ones(6,1); % Upper bounds: cannot exceed 1 ton of each ore (adjust if needed)
ctype = "SSSSS"; % 'S' indicates equality or inequality constraints (depending on your problem)
vartype = "CCCCCC"; % 'C' indicates continuous variables
% Solve the LP problem using glpk
[x, z, exitflag] = glpk(f, [A; A_ineq], [0; 0; 0; 0; b_ineq], lb, ub, ctype, vartype, 1);
% Display the results
disp('Optimal amounts of ores:');
disp(x);
disp('Minimum cost:');
disp(z);
JSBDb2VmZmljaWVudHMgZm9yIHRoZSBjb3N0IGZ1bmN0aW9uIChjb3N0IHBlciB0b24gb2YgZWFjaCBvcmUpCmYgPSBbMjc7IDI1OyAzMjsgMjI7IDIwOyAyNF07CgolIEluZXF1YWxpdHkgZm9yIGltcHVyaXRpZXMgKGltcHVyaXR5IGxpbWl0IGNvbnN0cmFpbnQpCkFfaW5lcSA9IFs0MCAxNSAzMCA1MCAzNSAyOV07CgolIE1heGltdW0gaW1wdXJpdHkgbGV2ZWwgKGV4YW1wbGUpCmJfaW5lcSA9IDUwOyAgJSBTZXQgdG8geW91ciBpbXB1cml0eSBsaW1pdAoKJSBUb3RhbCB0b24gY29uc3RyYWludCAoZXF1YWxpdHkpCkFlcSA9IFsxIDEgMSAxIDEgMV07CmJlcSA9IDE7CgolIE1ldGFsIGNvbnRlbnQgcmVxdWlyZW1lbnRzCkEgPSBbLTE5IC00MyAtMTcgLTIwIDAgLTEyOyAKICAgICAtMTUgLTEwIDA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