Examples of Matlab and GAMS to Solve Three LP/ NLP Problems

Similar documents
Linear Programming Notes V Problem Transformations

Chapter 6. Linear Programming: The Simplex Method. Introduction to the Big M Method. Section 4 Maximization and Minimization with Problem Constraints

4.6 Linear Programming duality

Nonlinear Programming Methods.S2 Quadratic Programming

LECTURE 5: DUALITY AND SENSITIVITY ANALYSIS. 1. Dual linear program 2. Duality theory 3. Sensitivity analysis 4. Dual simplex method

Solving Linear Programs in Excel

IEOR 4404 Homework #2 Intro OR: Deterministic Models February 14, 2011 Prof. Jay Sethuraman Page 1 of 5. Homework #2

Linear Programming. March 14, 2014

9.4 THE SIMPLEX METHOD: MINIMIZATION

1 Solving LPs: The Simplex Algorithm of George Dantzig

Linear Programming I

Lecture 3. Linear Programming. 3B1B Optimization Michaelmas 2015 A. Zisserman. Extreme solutions. Simplex method. Interior point method

Equations, Inequalities & Partial Fractions

EXCEL SOLVER TUTORIAL

CHAPTER 11: BASIC LINEAR PROGRAMMING CONCEPTS

Linear Programming. Solving LP Models Using MS Excel, 18

1 Introduction. Linear Programming. Questions. A general optimization problem is of the form: choose x to. max f(x) subject to x S. where.

Max Flow. Lecture 4. Optimization on graphs. C25 Optimization Hilary 2013 A. Zisserman. Max-flow & min-cut. The augmented path algorithm

Chapter 2 Solving Linear Programs

Introduction to Linear Programming (LP) Mathematical Programming (MP) Concept

Mathematical finance and linear programming (optimization)

Standard Form of a Linear Programming Problem

3.1. Solving linear equations. Introduction. Prerequisites. Learning Outcomes. Learning Style

LU Factorization Method to Solve Linear Programming Problem

Special Situations in the Simplex Algorithm

GENERALIZED INTEGER PROGRAMMING

Linear Programming. April 12, 2005

56:171 Operations Research Midterm Exam Solutions Fall 2001

Using the Simplex Method to Solve Linear Programming Maximization Problems J. Reeb and S. Leavengood

Linear Programming for Optimization. Mark A. Schulze, Ph.D. Perceptive Scientific Instruments, Inc.

Chapter 6: Sensitivity Analysis

Duality in Linear Programming

2.3. Finding polynomial functions. An Introduction:

Practical Guide to the Simplex Method of Linear Programming

Linear Programming Supplement E

Linear Programming Notes VII Sensitivity Analysis

Operation Research. Module 1. Module 2. Unit 1. Unit 2. Unit 3. Unit 1

LECTURE: INTRO TO LINEAR PROGRAMMING AND THE SIMPLEX METHOD, KEVIN ROSS MARCH 31, 2005

Sensitivity Analysis 3.1 AN EXAMPLE FOR ANALYSIS

DISTRIBUTION OF LOADSON PILE GROUPS

Tutorial: Using Excel for Linear Optimization Problems

LINEAR PROGRAMMING WITH THE EXCEL SOLVER

Linear Program Solver

15.053/8 February 26, 2013

OPRE 6201 : 2. Simplex Method

Agricultural and Environmental Policy Models: Calibration, Estimation and Optimization. Richard E. Howitt

Design Project 2. Sizing of a Bicycle Chain Ring Bolt Set. Statics and Mechanics of Materials I. ENGR 0135 Section 1040.

information available. There is a tremendous amount of sensitivity information, or information

SECOND DERIVATIVE TEST FOR CONSTRAINED EXTREMA

3.1 Solving Systems Using Tables and Graphs

MATLAB and Big Data: Illustrative Example

Schooling, Political Participation, and the Economy. (Online Supplementary Appendix: Not for Publication)

4 UNIT FOUR: Transportation and Assignment problems

Solving Systems of Linear Equations Using Matrices

Solving Linear Programs

Chapter 13: Binary and Mixed-Integer Programming

Solutions Of Some Non-Linear Programming Problems BIJAN KUMAR PATEL. Master of Science in Mathematics. Prof. ANIL KUMAR

Linear Programming Problems

Basic Components of an LP:

CONTENTS. CASE STUDY W-3 Cost Minimization Model for Warehouse Distribution Systems and Supply Chain Management 22

Linear Programming in Matrix Form

1.5 SOLUTION SETS OF LINEAR SYSTEMS

ROUTH S STABILITY CRITERION

Using EXCEL Solver October, 2000

24. The Branch and Bound Method

USING EXCEL SOLVER IN OPTIMIZATION PROBLEMS

ALGEBRA 2 CRA 2 REVIEW - Chapters 1-6 Answer Section

This exposition of linear programming

INTEGER PROGRAMMING. Integer Programming. Prototype example. BIP model. BIP models

Maximizing volume given a surface area constraint

Chapter 5. Linear Inequalities and Linear Programming. Linear Programming in Two Dimensions: A Geometric Approach

USING EXCEL 2010 TO SOLVE LINEAR PROGRAMMING PROBLEMS MTH 125 Chapter 4

Summary of specified general model for CHP system

An Appraisal Tool for Valuing Forest Lands

CS3220 Lecture Notes: QR factorization and orthogonal transformations

Can linear programs solve NP-hard problems?

OPTIMAL DESIGN OF A MULTITIER REWARD SCHEME. Amir Gandomi *, Saeed Zolfaghari **

Question 2: How do you solve a matrix equation using the matrix inverse?

Using CPLEX. =5 has objective value 150.

CHAPTER 3. INTRODUCTION TO MATRIX METHODS FOR STRUCTURAL ANALYSIS

Mathematics. Mathematical Practices

What is Linear Programming?

3. Evaluate the objective function at each vertex. Put the vertices into a table: Vertex P=3x+2y (0, 0) 0 min (0, 5) 10 (15, 0) 45 (12, 2) 40 Max

A Utility Maximization Example

Simplex method summary

Zeros of Polynomial Functions

Solving Linear Programs using Microsoft EXCEL Solver

Operation Count; Numerical Linear Algebra

Typical Linear Equation Set and Corresponding Matrices

Module1. x y 800.

Solving Mass Balances using Matrix Algebra

The Correlation Coefficient

1.2 Solving a System of Linear Equations

Basic Properties of Rational Expressions

Torgerson s Classical MDS derivation: 1: Determining Coordinates from Euclidean Distances

Land Expectation Value Calculation in Timberland Valuation

Transcription:

Examples of Matlab and GAMS to Solve Three LP/ NLP Problems 1. Fisheries example on NLP problem solved in GAMS. Problem and solution are given here. 2. The forester responsible for managing of 3,038 ha of southern hardwoods wants to convert this land to a regulated pine plantation. The pine plantation will be managed with a 20-year rotation and the conversion is to be done in 20 years. The forester intends to maximize pulpwood production while doing this conversion. The conversion will require that one-quarter of the total forest area be harvested and replanted in each of four (5-year) planning periods. The initial forest consists of five compartments. The area and expected yield of hardwood pulpwood by compartment is shown in the following table. Projected Hardwood Pulpwood Production (Green Tons/ha) Area Period Compartment (ha) 1 2 3 4 1 722 35.6 52.2 74.2 101.8 2 621 53.4 73.3 104.9 148.4 3 469 113.9 162.7 225.3 303.3 4 545 92.8 135.0 185.4 258.2 5 681 39.9 56.5 76.7 102.0 Use Matlab s linprog function to solve this LP problem. Here is the LP problem statement: Max Z = (35.6 x 11 + 53.4 x 21 + 113.9 x 31 + 92.8 x 41 + 39.9 x 51 ) + (52.2 x 12 + 73.3 x 22 + 162.7 x 32 + 135.0 x 42 + 56.5 x 52 ) + (74.2 x 13 + 104.9 x 23 + 225.3 x 33 + 185.4 x 43 + 76.7 x 53 ) + (101.8 x 14 + 148.4 x 24 + 303.3 x 34 + 258.2 x 44 + 102.0 x 54 ) s.t. x 11 + x 12 + x 13 + x 14 722 (Area of compartment #1) x 21 + x 22 + x 23 + x 24 621 (Area of compartment #2) x 31 + x 32 + x 33 + x 34 469 (Area of compartment #3) x 41 + x 42 + x 43 + x 44 545 (Area of compartment #4) x 51 + x 52 + x 53 + x 54 681 (Area of compartment #5) x 11 + x 21 + x 31 + x 41 + x 51 = 759.5 (Even harvest period #1) x 12 + x 22 + x 32 + x 42 + x 52 = 759.5 (Even harvest period #2) x 13 + x 23 + x 33 + x 43 + x 53 = 759.5 (Even harvest period #3) x 14 + x 24 + x 34 + x 44 + x 54 = 759.5 (Even harvest period #4) x 11, x 21, x 31, x 41, x 51, x 12, x 22, x 32, x 42, x 52, x 13, x 23, x 33, x 43, x 53, x 14, x 24, x 34, x 44, x 54 0 (non-negatively) Matlab code provided below. Here are the answers.

When simplex algorithm is NOT used: exitflag = 1 Value of the objective function = 3.8947e+005 Harvest by compartments and time measured across a row 391.0411 0.0000 0.0000 0.0000 368.4589 330.9589 116.0000 0.0000 0.0000 312.5411 0.0000 505.0000 0.0000 254.5000 0.0000 0.0000 0.0000 469.00 290.5000 0.0000 Restriction that annual harvest amounts to 759.5 ha 759.5000 759.5000 759.5000 759.5000 Restriction that no more than total compartment area is harvested 722.0000 621.0000 469.0000 545.0000 681.0000 When simplex is on, the answers are different, indicating multiple solutions. exitflag = 1 Value of the objective function = 3.8947e+005 Harvest by compartments and time measured across a row 78.5000 0 0 0 681.0000 643.5000 116.0000 0 0 0 0 505.0000 0 254.5000 0 0 0 469.0000 290.5000 0 Restriction that annual harvest amounts to 759.5 ha 759.5000 759.5000 759.5000 759.5000 Restriction that no more than total compartment area is harvested 722 621 469 545 681 NOW assume a discount rate of 5% per year and a pulpwood price of $20 per green ton. The harvest plan differs because current harvests are valued higher than later ones!! exitflag = 1 Value of the objective function = 4.0676e+006

Harvest by compartments and time measured across a row 0 116.0000 0 0 643.5000 722.0000 0 0 0 37.5000 0 505.0000 254.5000 0 0 0 0 214.5000 545.0000 0 Restriction that annual harvest amounts to 759.5 ha 759.5000 759.5000 759.5000 759.5000 Restriction that no more than total compartment area is harvested 722 621 469 545 681

(Main Program) % Forest management problem @ G. Cornelis van Kooten tic c1 = [35.6 52.2 74.2 101.8; 53.4 73.3 104.9 148.4; 113.9 162.7 225.3 303.3; 92.8 135.0 185.4 258.2; 39.9 56.5 76.7 102.0]; % Multiply rows of c1 by $20 times discount factors 0.885, 0.6936... discount = [1/(1.05^2.5) 1/(1.05^7.5) 1/(1.05^12.5) 1/(1.05^17.5)]; c2=20*discount'; c3=repmat(c2,1,5).*c1'; A = [ones(1,4), zeros(1,16); zeros(1,4), ones(1,4), zeros(1,12); zeros(1,8), ones(1,4), zeros(1,8); zeros(1,12), ones(1,4), zeros(1,4); zeros(1,16), ones(1,4)]; Aeq = [1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0; 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0; 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0; 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1]; beq = [759.5 759.5 759.5 759.5]; b = [722 621 469 545 681]; lb = zeros(1, 20); % Creating the correct objective function coefficient vector % Substitute c3 for c1' (NOTE c3 has already been transposed) f = -reshape(c3, 1, 20); options = optimset('largescale', 'off', 'simplex', 'on'); %Calling the LP function [x,fval,exitflag] = linprog(f,a,b,aeq,beq,lb,[],[],options); y=reshape(x,4,5); exitflag 'Value of the objective function' -fval 'Harvest by compartments and time measured across a row' y 'Restriction that annual harvest amounts to 759.5 ha' sum(y') 'Restriction that no more than total compartment area is harvested' sum(y)

3. A rural hospital wants to maximize the profit (revenue minus expenses) that it gets from patients hospitalized under its care. Annual revenue depends on the numbers of medical (x 1 ) and surgical (x 2 ) patients admitted. Since medical and surgical patients impose costs upon each other, the profit function is nonlinear. The hospital identifies three constraints. The mathematical programming problem is as follows: Max π = 13 x 1 + 6 x 1 x 2 +5 x 2 +1/x 2 (profit in 000s $) Subject to 2 x 2 1 + 4 x 2 90 (nursing capacity in 000s labor-days) 3 x 1 + x 2 75 (X-ray capacity in 000s) 8 x 1 2 x 2 61 (materials budget in 000s $) x 1, x 2 0 Solution using Matlab. The answer is: x 1 = 6.0663 x 2 = 4.1003. These values need to be multiplied by 1,000; thus, 6066 medical and 4100 surgical patients. The exit flag is 1. The objective value is 248.8457, or $248,846 in profit. GAMS leads to the following: (GAMS code here) Objective value = 248.8457; x 1 = 6.066 x 2 = 4.100; and the shadow prices for the three constraints Nursing capacity = 1.521 X-ray capacity = 0.699 Materials budget = 0 (excess budget)

Main Program % Rural hospital. Nonlinear programming @G. Cornelis van Kooten clear all; x0=[1 1]; lb = [0 0]; %A = [-0.5 0.1-1; -1 0.1-1]; b = [-60, -40]; options=optimset('largescale','off'); %options=optimset('largescale','off', 'TolCon', 1.0000e-15); %[x,fval,exitflag]=fmincon('profit',x0,a,b,[],[],lb,[],[],options); [x,fval,exitflag]=fmincon('objective',x0,[],[],[],[],lb,[],... @constraint,options); exitflag 'Values of activity levels' x 'Objective value' -fval Two Function Files (objective.m and constraint.m) % Profit function for HW#2 (2009) function f=objective(x) f=-(13*x(1)+6*x(1)*x(2)+5*x(2)+1/x(2)); %This function contains the inequality and equality constraint equations % Note that inequality constraints must by of <= form function [cin,ceq]=constraint(x) cin=[2*x(1)*x(1)+4*x(2)-90; x(1)+x(2)^3-75; 8*x(1)-2*x(2)-61]; ceq=[];

GAMS Code $Title Nonlinear Programming Example SETS i index 1 /1*2/ ; VARIABLES z objective value ; Positive VARIABLE x; EQUATIONS OBJ Objective function CON1 Constraint 1 CON2 Constraint 2 CON3 Constraint 3 ; * ------------------------------------------------------------- * Construction of the actual NLP model * ------------------------------------------------------------- OBJ.. z =E= 13*x('1') + 6*x('1')*x('2') + 5*x('2') + 1/x('2'); CON1.. 2*x('1')**2 + 4*x('2') =L= 90; CON2.. x('1') + x('2')**3 =L= 75; CON3.. 8*x('1') - 2*x('2') =L= 61; x.l(i) = 1; Model Nurse /all/; solve Nurse using NLP maximizing z;