[go: up one dir, main page]

0% found this document useful (0 votes)
10 views6 pages

258629A EE5096-InA1

The document outlines a series of linear programming tasks aimed at maximizing profits or values under specific constraints. Each task defines coefficients for inequalities, objective functions, and solves the problems using the 'linprog' function, displaying optimal production or allocation results. The outputs include optimal quantities of products or resources and the corresponding maximum profits or values achieved.

Uploaded by

Kalindu Liyanage
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

258629A EE5096-InA1

The document outlines a series of linear programming tasks aimed at maximizing profits or values under specific constraints. Each task defines coefficients for inequalities, objective functions, and solves the problems using the 'linprog' function, displaying optimal production or allocation results. The outputs include optimal quantities of products or resources and the corresponding maximum profits or values achieved.

Uploaded by

Kalindu Liyanage
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Task 01 –

% Define the coefficients for the inequalities

A = [3, 4;

1, 2;

2, 3;

2, 0];

b = [2400; 900; 1600; 1200];

% Define the objective function coefficients (to maximize 5x + 9y)

f = [-5; -9];

% Lower bounds for x and y (non-negative constraints)

lb = [0; 0];

% Solve the linear programming problem

[x, fval] = linprog(f, A, b, [], [], lb);

% Calculate the maximum profit

max_profit = -fval;

% Display the results

disp(['Number of R1 to produce: ', num2str(x(1))]);

disp(['Number of R2 to produce: ', num2str(x(2))]);

disp(['Maximum profit: ', num2str(max_profit), 'p']);


Out put –

Optimal number of R1 boards to produce: 500.00

Optimal number of R2 boards to produce: 200.00

Maximum profit: 4300.00

Task 02 –

% Define coefficients for inequalities

A = [4, 1, 1;

3, 4, 6;

2, 4, 1;

1, 1, 2];

b = [19; 30; 25; 15];

% Define objective function coefficients (to maximize 5x1 + 4x2 + 6x3)

f = [-5; -4; -6];

% Lower bounds (non-negative constraints)

lb = [0; 0; 0];

% Solve the linear programming problem

[x, fval] = linprog(f, A, b, [], [], lb);

% Calculate maximum value

max_z = -fval;
% Display results

disp(['Optimal values:']);

disp(['x₁ = ', num2str(x(1))]);

disp(['x₂ = ', num2str(x(2))]);

disp(['x₃ = ', num2str(x(3))]);

disp(['Maximum z = ', num2str(max_z)]);

Output –

Optimal value of x1: 4.00

Optimal value of x2: 0.00

Optimal value of x3: 3.00

Maximum value of Z: 38.00

Task 03 –

% Define coefficients for inequalities

A = [4, 2, 1; % Budget constraint (£60 million)

1, 1, 1; % Pilot constraint (25 aircraft)

2, 1.5, 1]; % Maintenance constraint (30 units)

b = [60; 25; 30];

% Define objective function coefficients (maximize profit in millions)

f = [-0.4; -0.3; -0.15]; % Negative for maximization


% Lower bounds (non-negative aircraft count)

lb = [0; 0; 0];

% Solve the linear programming problem

[x, fval] = linprog(f, A, b, [], [], lb);

% Calculate maximum profit

max_profit = -fval;

% Display results

disp(['Optimal fleet composition:']);

disp(['Long-range aircraft: ', num2str(round(x(1)))]);

disp(['Medium-range aircraft: ', num2str(round(x(2)))]);

disp(['Short-range aircraft: ', num2str(round(x(3)))]);

disp(['Maximum profit: £', num2str(max_profit), ' million']);

Output –

Optimal number of Long-range aircraft: 0.00

Optimal number of Medium-range aircraft: 20.00

Optimal number of Short-range aircraft: 0.00

Maximum Profit (£ million): 6.00

Task 04 –

% Define coefficients for inequalities


A = [2, 1, 0, 1;

1, 0, 1, 1;

1, 1, 3, 2];

b = [3; 4; 10];

% Define objective function (maximize 6x₁ + x₂ + 2x₃ + 4x₄)

f = [-6; -1; -2; -4]; % Negative coefficients for maximization

% Lower bounds (non-negative constraints)

lb = [0; 0; 0; 0];

% Solve the linear programming problem

[x, fval] = linprog(f, A, b, [], [], lb);

% Calculate maximum value

max_f = -fval;

% Display results

disp('Optimal solution:');

disp(['x₁ = ', num2str(x(1))]);

disp(['x₂ = ', num2str(x(2))]);

disp(['x₃ = ',

Output –

Optimal value of x1: 0.00


Optimal value of x2: 0.00

Optimal value of x3: 1.00

Optimal value of x4: 3.00

Maximum value of f: 14.00

You might also like