% Coefficients for the cost function (cost per ton of each ore)
f = [27; 25; 32; 22; 20; 24];
% Metal constraints: A, B, C, D
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];
% Impurities constraint
A_ineq = [40 15 30 50 35 29];
% Bounds on the variables
lb = zeros(6,1); % Non-negativity
% Total ton constraint
Aeq = [1 1 1 1 1 1]; % Sum of ores must equal 1 ton
beq = 1;
% Maximum impurity level (can be adjusted based on threshold)
b_ineq = 50; % Example impurity threshold
% Use intlinprog to solve the problem
x = intlinprog(f, 1:6, A_ineq, b_ineq, Aeq, beq, lb, []);
JSBDb2VmZmljaWVudHMgZm9yIHRoZSBjb3N0IGZ1bmN0aW9uIChjb3N0IHBlciB0b24gb2YgZWFjaCBvcmUpCmYgPSBbMjc7IDI1OyAzMjsgMjI7IDIwOyAyNF07CgolIE1ldGFsIGNvbnN0cmFpbnRzOiBBLCBCLCBDLCBECkEgPSBbLTE5IC00MyAtMTcgLTIwIDAgLTEyOyAKICAgICAtMTUgLTEwIDAgLTEyIC0yNCAtMTg7IAogICAgIC0xMiAtMjUgMCAwIC0xMCAtMTY7IAogICAgIC0xNCAtNyAtNTMgLTE4IC0zMSAtMjVdOwoKJSBJbXB1cml0aWVzIGNvbnN0cmFpbnQKQV9pbmVxID0gWzQwIDE1IDMwIDUwIDM1IDI5XTsKCiUgQm91bmRzIG9uIHRoZSB2YXJpYWJsZXMKbGIgPSB6ZXJvcyg2LDEpOyAgJSBOb24tbmVnYXRpdml0eQoKJSBUb3RhbCB0b24gY29uc3RyYWludApBZXEgPSBbMSAxIDEgMSAxIDFdOyAgJSBTdW0gb2Ygb3JlcyBtdXN0IGVxdWFsIDEgdG9uCmJlcSA9IDE7CgolIE1heGltdW0gaW1wdXJpdHkgbGV2ZWwgKGNhbiBiZSBhZGp1c3RlZCBiYXNlZCBvbiB0aHJlc2hvbGQpCmJfaW5lcSA9IDUwOyAgJSBFeGFtcGxlIGltcHVyaXR5IHRocmVzaG9sZAoKJSBVc2UgaW50bGlucHJvZyB0byBzb2x2ZSB0aGUgcHJvYmxlbQp4ID0gaW50bGlucHJvZyhmLCAxOjYsIEFfaW5lcSwgYl9pbmVxLCBBZXEsIGJlcSwgbGIsIFtdKTsK