Optimizations and Programming. Abdelkhalak El Hami

Читать онлайн.
Название Optimizations and Programming
Автор произведения Abdelkhalak El Hami
Жанр Техническая литература
Серия
Издательство Техническая литература
Год выпуска 0
isbn 9781119818267



Скачать книгу

A, b, Aeq, beq): solves the problem with the equality constraints Aeqx = beq. Set A=[ ] and b=[ ] if no inequalities exist;

       – x = linprog(f, A, b, Aeq, beq, lb, ub): defines a set of lower and upper bounds on the design variables, x, so that the solution is always in the range lb ≤ x ≤ ub. Set Aeq=[ ] and beq=[ ] if no equalities exist;

       – x = linprog(f, A, b, Aeq, beq, lb, ub, x0): defines the starting point at x0 (only used for the active-set algorithm);

       – x = linprog(f, A, b, Aeq, beq, lb, ub, x0, options): minimizes with the specified options;

       – [x, fval] = linprog(...): returns the value of the objective function at the solution x;

       – [x, fval, exitflag] = linprog(...): returns a value exitflag that describes the exit condition;

       – [x, fval, exitflag, output] = linprog(...): returns a structure output that contains information about the optimization process;

       – [x, fval, exitflag, output, lambda] = linprog(...): returns a structure output whose fields contain the Lagrange multipliers λ at the solution x.

      EXAMPLE 1.14.– Consider the linear program:

      [1.25]image

      The following code can be executed to compute this example.

      1 1 variables = {'x1', 'x2', 'x3', 'x4', 'x5'}; % construct the vector x

      2 2 n = length(variables);

      3 3 for i = 1:n % create the indices of x

      4 4 eval([variables{i}, ' = ', num2str(i), ';']);

      5 5 end

      6 6 lb = zeros(1, n);

      7 7 lb([x1, x2]) = [5, 1]; % add the bounds of the variables x1,x2

      8 8 ub = Inf(1, n);

      9 9 A = zeros(3, n); % create the matrix A

      10 10 b = zeros(3, 1); % create the vector b

      11 11 % define the constraints

      12 12 A(1, [x1, x2, x3, x4]) = [1, 4, -2, -1]; b(1) = 8;

      13 13 A(2, [x1, x2, x3, x4]) = [1, 3, 2, -1]; b(2) = 10;

      14 14 A(3, [x1, x2, x3, x4, x5]) = [2, 1, 2, 3, -1]; b(3) = 20;

      15 15 Aeq = zeros(1, n); % create the matrix Aeq

      16 16 beq = zeros(1, 1); % create the vector beq

      17 17 % define the equality constraints

      18 18 Aeq(1, [x1, x2, x3, x4, x5]) = [1, 3, -4, -1, 1]; beq(1) = 7;

      19 19 c = zeros(n, 1); % create the vector c

      20 20 c([x1 x2 x3 x4 x5]) = [-2; -3; 1; 4; 1];

      21 21 % call linprog solver

      22 22 [x, objVal] = linprog(c, A, b, Aeq, beq, lb, ub);

      23 23 for i = 1:n

      24 24 fprintf('%s \t %20.4f\n', variables{i}, x(i))

      25 25 end

      26 26 fprintf(['The value of the objective function is' '%20.4f\n'],

      27 27 objVal)

       For a color version of this code, see www.iste.co.uk/radi/optimizations.zip

      Executing this code produces the following results:

image

      Конец ознакомительного фрагмента.

      Текст предоставлен ООО «ЛитРес».

      Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.

      Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.

/9j/4AAQSkZJRgABAQEBLAEsAAD/7SNiUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAACUcAgAAAgAA HAJQAAxTYW1pIE1lbmFzY2UcAgUACGxheW91dCAxADhCSU0EJQAAAAAAEOCT4VfQf7s1WRbpbWQ0 +DU4QklNBDoAAAAAAOUAAAAQAAAAAQAAAAAAC3ByaW50T3V0cHV0AAAABQAAAABQc3RTYm9vbAEA AAAASW50ZWVudW0AAAAASW50ZQAAAABDbHJtAAAAD3ByaW50U2l4dGVlbkJpdGJvb2wAAAAAC3By aW50ZXJOYW1lVEVYVAAAAAEAAAAAAA9wcmludFByb29mU2V0dXBPYmpjAAAADABQAHIAbwBvAGYA IABTAGUAdAB1AHAAAAAAAApwcm9vZlNldHVwAAAAAQAAAABCbHRuZW51bQAAAAxidWlsdGluUHJv b2YAAAAJcHJvb2ZDTVlLADhCSU0EOwAAAAACLQAAABAAAAABAAAAAAAScHJpbnRPdXRwdXRPcHRp b25zAA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