Common-analog algorithm suite - integer linear programming (branch and bound method), integer nonlinear programming (Monte Carlo method)

---- integer linear programming branch and bound

What is the integer programming?

Linear programming variables (partial or complete) limit integer, called integer programming. If the linear programming model, the variables restricted to integer, called integer linear programming. Currently popular method of solving integer programming, often apply only to integer linear programming. There is no way everything can be solved efficiently integer programming.

Classification Integer Programming

    - 变量全限制为整数时,称(完全)整数规划

    - 变量部分限制为整数时,称混合整数规划            

What is the branch and bound method

Principle is as follows:

Has maximized integer programming problem A , and its corresponding linear programming problem is B , the solution of the problem B began, if it does not meet the optimal solution A integer condition, then B 's optimal objective function must be the A 's the optimal objective function \ (z ^ * \) upper bound \ (\ overline {Z} \) ; and a objective function value of any feasible solution would be \ (z ^ * \) a lower bound \ (\ underline Z \) , the branch and bound method is the B method of the sub-region into the feasible region. Gradually decrease \ (\ overline z \) and an increased \ (\ underline z \) eventually find the \ (z ^ * \)

It is essentially a binary backtracking algorithm maximum approximation. Matlab algorithm is as follows :( a strong warning , (Does not validate) Because of lazy, did not verify the correctness of the algorithm to verify the idea of ​​a code problem did not look up, and if there is wrong, be sure to contact ~~)

    % c,A,Aeq,Beq,LB,UB,是linprog函数的相关参数,知道了它们就可以求出对应的线性规划最优解,
    % now是目前已经知道的整数解的最大值
    function y = control(c,A,Aeq,Beq,LB,UB,now)
        ret = 0; 
        [x,fval] = linprog(c,A,Aeq,Beq,LB,UB); % x是最优解的解向量,fval是对应的函数值
        if fval < now  
             y = fval;
             return;
        end   % 如果得到的当前最优解fval小于已知的now,那说明最优整数解不在这个区间,则剪枝返回。
        for i = 1 : length(x)
            if rem(x(i),1) ~= 0  % rem(x,1)如果返回值不为0,则表示是小数。遍历x,找到第一个小数xi.
             NUB = UB; 
             NLB = LB;
             NUB(i) = floor(x(i)); % 把xi对应的上界更新为xi的向下取整。
             NLB(i) = ceil(x(i)); % 把xi对应的下届更新为xi的向上取整。
             fval1 = control(c,A,Aeq,Beq,LB,NUB,now);  %分成了两个区间, 原来下界~向下取整
            now = max(fval1,now);
             fval2 = control(c,A,Aeq,Beq,NLB,UB,now);  % 向上取整~原来上届
             ret = max(ret,fval1); % 更新得到整数最优解,并退出。
             ret = max(ret,fval2); 
             break
            end
            if  i == length(x)  %如果每个xi都是整数,那说明当前已经是整数最优,用j记录一下
             j = length(x)+1;
            end
        end
        if j == length(x)+1   %如果当前已经是整数最优,返回fval,否则返回ret。
             y = fval;
        else 
             y = ret; 
        end
   end

Nonlinear integer programming - Monte Carlo algorithm (random sampling)

What is linear programming?

That argument is no longer linear programming. Yes is this.

Monte Carlo algorithm

For nonlinear integer programming is not yet a mature and accurate solution method, then find a relatively satisfactory solution has become the main demand.

Monte Carlo algorithm is a large number of random sampling enumerate solution, there is a solution in order to achieve its function value falls we expect high value area (Do not ask me what is a high-value area)。

So how many times the specific enumeration better? This is relative to the problem, for example:

\ (0 \ leq x_i \ leq 99, 1 \ leq i \ leq 5, y = x_1 ^ 2 + x_2 ^ 2 + 3x_3 ^ 2 + 4x_4 ^ 2 + 2x_5 ^ 2-8x_1-2x_2-3x_3-x_4-2x_5 \) ,

The size of the solution space \ (^ 5 100 ^ {10} = 10 \) , too, can not enumerate

If you select a random sample 1e6, assuming that most of the advantage is not an isolated singular point, and set the objective function value area of high probability falls acceptable 0.00001, then there is a probability value falls area high point is 1 \ (0.99999 {1000000} ^ \) \ (\ approx \) .999954602, obviously this probability is acceptable, that is, we believe that through random sampling 1e6, is to meet the expectations of the solution can be obtained.

Random sampling algorithms do not write, because too lazy (Because it would not)。

Today feeling: matlab library function is really more basic grammar or not, ah, and digital-analog algorithm quite interesting, although the tall, in fact, it did.

Guess you like

Origin www.cnblogs.com/backkom-buaa/p/11494398.html