www.gusucode.com > optim 案例源码 matlab代码程序 > optim/ExaminetheMILPSolutionandProcessExample.m
%% Examine the MILP Solution and Process % Call |intlinprog| with more outputs to see solution details and process. %% % The goal is to solve the problem % % $$ \mathop {\min }\limits_x \left( { - 3{x_1} - 2{x_2} - {x_3}} \right) % {\rm{\ subject\ to }}\left\{ {\begin{array}{*{20}{l}} % {{x_3}{\rm{\ binary}}}\\ % {{x_1},{x_2} \ge 0}\\ % {{x_1} + {x_2} + {x_3} \le 7}\\ % {4{x_1} + 2{x_2} + {x_3} = 12.} % \end{array}} \right. $$ % %% % Specify the solver inputs. f = [-3;-2;-1]; intcon = 3; A = [1,1,1]; b = 7; Aeq = [4,2,1]; beq = 12; lb = zeros(3,1); ub = [Inf;Inf;1]; % enforces x(3) is binary %% % Call |intlinprog| with all outputs. [x,fval,exitflag,output] = intlinprog(f,intcon,A,b,Aeq,beq,lb,ub) %% % The output structure shows |numnodes| is |0|. This means |intlinprog| % solved the problem before branching. This is one indication that the result % is reliable. Also, the |absolutegap| and |relativegap| fields are |0|. % This is another indication that the result is reliable.