Академический Документы
Профессиональный Документы
Культура Документы
18. The Excel sheet picture on the right shows the result of a macro that automatically fills up the cells in range
A2:B13. This macro should not be accessed from any other module than the module it is defined in. Fill in the
underlined blanks in the incomplete VBA procedure below.
19. Given the following linear program (LP) formulation, write the necessary MATLAB commands that will
provide the optimal solution using the linprog function to this LP as instructed below.
Maximize subject to
50 1 + 70 2 + 503 + 704
150 1 + 200 2 = 45000
135 3 + 180 4 = 36000
1 + 2 300
3 + 4 250
1 + 3 250
2 + 4 350
1, 2, 3, 4 0
Write all of the following commands as if you are typing in a MATLAB script file.
a. Define the objective function coefficients: f = [-50; -70; -50; -70];
b. Define the constraint coefficients (use as many arrays as necessary for different types of constraints): A=[1 1
0 0;0 0 1 1;1 0 1 0;0 1 0 1] B=[150 200 0 0;0 0 135 180
] c. Define the Right-Hand-Side values of constraints (use as many arrays as necessary): a=[300; 250; 250; 350]
or a = [300 250 250 350]' b=[45000; 36000] or b = [45000 36000]'
d. Define the lower bounds on decision variables: lb = zeros(4,1)
e. Solve the LP to optimality and assign the values for x and lambda: [x,lambda] = linprog(f,A,a,B,b,lb);
f. Write the command for finding the sum of the four decision variables and assigning this value to a variable
named totalProduction: totalProduction = x(1)+x(2)+x(3)+x(4)
There are three electric power plants that supply the needs of two cities. If power plant supplies electricity to
city there is a fixed cost of dollars and the cost of each kilowatt-hour (kwh) of electricity supplied is dollars,
where = 1,2,3 and = 1,2. The arrays for the fixed cost and cost per kWh are given as below. = [50 40 30] =
[ 10 15 20 10 5 25 ]
a. Write a MATLAB
function that calculates the total cost of kWh of electric supply from plant to city such that the cost
coefficients are defined in the function instead of being input values.
b. Write the MATLAB statements that will calculate the cost of supplying 100 kWh of electricity for each plantcity pair and displays the cost in tabular format as shown below