fork download
  1. % Coefficients for the cost function (cost per ton of each ore)
  2. f = [27; 25; 32; 22; 20; 24];
  3.  
  4. % Metal constraints: A, B, C, D
  5. A = [-19 -43 -17 -20 0 -12;
  6. -15 -10 0 -12 -24 -18;
  7. -12 -25 0 0 -10 -16;
  8. -14 -7 -53 -18 -31 -25];
  9.  
  10. % Impurities constraint
  11. A_ineq = [40 15 30 50 35 29];
  12.  
  13. % Bounds on the variables
  14. lb = zeros(6,1); % Non-negativity
  15.  
  16. % Total ton constraint
  17. Aeq = [1 1 1 1 1 1]; % Sum of ores must equal 1 ton
  18. beq = 1;
  19.  
  20. % Maximum impurity level (can be adjusted based on threshold)
  21. b_ineq = 50; % Example impurity threshold
  22.  
  23. % Use intlinprog to solve the problem
  24. x = intlinprog(f, 1:6, A_ineq, b_ineq, Aeq, beq, lb, []);
  25.  
Success #stdin #stdout #stderr 0.13s 48948KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
error: 'intlinprog' undefined near line 24 column 5
error: called from
    /home/9HI1UN/prog.octave at line 24 column 3