Page 307 - 数学建模算法与应用
P. 307

第十章  目标规划的研究


                   nPlant = length(plant);
                   nCustomer = length(customer);
                   nDeviation = 12;

                   x = intlinprog(‘intvars’, [], ‘lb’, zeros(nPlant*nCustomer, 1), ‘ub’, [], ...
                   ‘Aeq’,  [],  ‘beq’,  [],  ‘Aineq’,  [],  ‘bineq’,  [],  ‘f’,  [],  ‘options’,  []);%
               构建约束矩阵
                   Aeq = [];

                   beq = [];
                   Aineq = [];
                   bineq = [];

                   lb = zeros(nPlant*nCustomer + nCustomer*2, 1);
                   ub = [];% 供应量约束
                   Atemp = sparse(nPlant, nPlant*nCustomer + nCustomer*2);
                   for i = 1:nPlant
                   Atemp(i, (i-1)*nCustomer+1:i*nCustomer) = -1*ones(1, nCustomer);
                   end

                   Aineq = [Aineq; Atemp];
                   bineq = [-a(:).’];% 需求量约束

                   Atemp = sparse(nCustomer, nPlant*nCustomer + nCustomer*2);
                   for j = 1:nCustomer
                   Atemp(j, 1:nPlant*nCustomer(nPlant*(j-1)+1:nPlant*j)) = 1*ones(1,
               nPlant);
                   Atemp(j, nPlant*nCustomer + j) = 1;

                   Atemp(j, nPlant*nCustomer + nCustomer + j) = -1;
                   end
                   Aineq = [Aineq; Atemp];

                   bineq = [bineq; b(:).’-Atemp(:, nPlant*nCustomer + 1:
               end)*zeros(nCustomer*2, 1)];% 特殊约束
                   Atemp = sparse(1, nPlant*nCustomer + nCustomer*2);
                   Atemp(1, nPlant*nCustomer + 5) = 1;



                                                                                      297
   302   303   304   305   306   307   308   309   310   311   312