0% found this document useful (0 votes)
3 views

Homework_1

The document contains solutions to three problems involving optimization using AMPL. Problem 1 focuses on minimizing the total time for a river-crossing scenario, yielding optimal entry and exit points. Problem 2 formulates a linear program for maximizing profits from ticket sales across different routes and fare classes, while Problem 3 addresses various exercises from a textbook using the simplex method.

Uploaded by

colin1898.mitbbs
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Homework_1

The document contains solutions to three problems involving optimization using AMPL. Problem 1 focuses on minimizing the total time for a river-crossing scenario, yielding optimal entry and exit points. Problem 2 formulates a linear program for maximizing profits from ticket sales across different routes and fare classes, while Problem 3 addresses various exercises from a textbook using the simplex method.

Uploaded by

colin1898.mitbbs
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

ORF 307 Homework 1 Solutions

Carson M Eisenach
Spring 2016
Problem 1. Make an AMPL model to solve the river-crossing problem described on slide 12
of Lecture 1.
In this problem we wish to perform an unconstrained minimization of the following ob-
jective
p p p
(a1 − x1 )2 + b21 (x1 − x2 )2 + w2 (x2 − a2 )2 + (w − b2 )2
t= + +
v1 v2 v3
Where x1 and x2 are the entry and exit points of the river, respectively, and w is the width
of the river. If you notice, we have simply summed the times on each section of the journey.
This total time then is the quantity we wish to minimize. Running the attached code in
AMPL yields an optimal solution of
x1 = −29.2497
x2 = −33.3952

Problem 2. Do question 1.2 in the textbook. Formulate the linear program on paper. Then
write an AMPL model and solve it (see lecture 1). Include the output in your HW.
First denote by 1 the route Ithaca-Newark, by 2 the route Newark-Boston and 3 the route
Ithaca-Boston. Then let J = {Y, B, M }, the set of fare classes and I = {1, 2, 3}. Allow xij
to be the variable corresponding to the number of fares of class j on route i and pij to be the
corresponding fare price. Let uij be the upperbound on the number of potential customers
on that particular route and class combination. The linear program can then be given as
follows.

X
maximize pij xij
(i,j)∈I×J
X X
subject to x1j + x3j ≤ 30
j∈J j∈J
X X
x2j + x3j ≤ 30
j∈J j∈J

xij ≤ uij for all (i, j) ∈ I × J


xij ≥ 0 for all (i, j) ∈ I × J
Using the attached code we can solve with AMPL for the maximum value yielding the
following output
ampl : model problem 2 . mod
ampl : s o l v e ;
MINOS 5 . 5 1 : o p t i m a l s o l u t i o n found .
8 i t e r a t i o n s , o b j e c t i v e 9790

1
Problem 3. Do exercises 2.3, 2.5, 2.10, 2.11, 2.12 and 2.13 in the textbook. You are
encouraged to use the applet mentioned at the top of the excercises section. For exercises
2.12 and 2.13, use 212 for the seed value and turn in either a screen shot or hand-written
rendition of the last dictionary of the last of the 10 problems.
For each pivot in exercises 2.3, 2.5, 2.10, and 2.11, you should select a variable with
positive coefficient in the objective function to have enter the basis. To select the variable to
leave the basis we choose the one that would become zero first. In this manner once we begin
from a feasible solution, the solution always remains feasible, while increasing the objective
value. Below are the list of pivots made according to this rule for 2.3, 2.5, 2.10, and 2.11.
2.3 Here we start with an infeasible dictionary so we must use the pivot tool with x0 to
solve this problem using the two phase simplex method. First we choose the most
infeasible to leave the basis first to get a feasible dictionary.
1. IN: x0 OUT: w1
2. IN: x2 OUT: x0
Now we have a feasible dictionary for Stage II of the simplex method, so we use this
dictionary with the original objective 2x1 −6x2 which in terms of this dictionary becomes
−12 + 8x1 + 6x3 − 6w1 .
1. IN: x1 OUT: w2
2. IN: x3 OUT: x1
This yields an optimal value of -3.
2.5 Here we start with an infeasible dictionary so we must use the pivot tool with x0 to
solve this problem using the two phase simplex method. First we choose the most
infeasible to leave the basis first to get a feasible dictionary.
1. IN: x0 OUT: w1
2. IN: x2 OUT: w2
3. IN: x1 OUT: x0
Now we have a feasible dictionary for Stage II of the simplex method, so we use this
dictionary with the original objective x1 +3x2 which in terms of this dictionary becomes
5 − 2w1 − 2w2 . We get lucky and see this is in fact optimal for the original problem
yielding an objective value of 5.
2.10 First we need to restate this problem in standard form which gives us
maximize 6x1 + 8x2 + 5x3 + 9x4
subject to x1 + x2 + x3 + x4 ≤ 1
− x1 − x2 − x3 − x4 ≤ −1
xi ≥ 0 for all i
We see again that we have an initially infeasible dictionary so we must use the pivot
tool with x0 to solve this problem using the two phase simplex method. First we choose
the most infeasible to leave the basis first to get a feasible dictionary.

2
1. IN: x0 OUT: w2
2. IN: x1 OUT: x0

Now we have a feasible dictionary for Stage II of the simplex method, so we use this
dictionary with the original objective 6x1 + 8x2 + 5x3 + 9x4 which in terms of this
dictionary becomes 6 + 2x2 − x3 + 3x4 − 6w2 .

1. IN: x4 OUT: x1

This yields an optimal value of 9.

2.11 First we need to restate this problem in standard form which gives us

maximize − x12 − 8x13 − 9x14 − 2x23 − 7x24 − 3x34


subject to − x12 − x13 − x14 ≤ −1
x12 − x23 − x24 ≤ 0
− x12 + x23 + x24 ≤ 0
− x13 − x23 + x34 ≤ 0
x13 + x23 − x34 ≤ 0
x14 + x24 + x34 ≤ 1
x12 , x13 , x14 , x23 , x24 , x34 ≥ 0

We see again that we have an initially infeasible dictionary so we must use the pivot
tool with x0 to solve this problem using the two phase simplex method. First we choose
the most infeasible to leave the basis first to get a feasible dictionary.

1. IN: x0 OUT: w1
2. IN: x12 OUT: w2
3. IN: x14 OUT: x0

Now we have a feasible dictionary for Stage II of the simplex method, so we use this
dictionary with the original objective −x12 − 8x13 − 9x14 − 2x23 − 7x24 − 3x34 which in
terms of this dictionary becomes −9 − 9w1 − 8w2 + 8w5 + 5x23 + x24 − 2x34 .

1. IN: w5 OUT: x13


2. IN: x24 OUT: x14
3. IN: x34 OUT: w4
4. IN: x23 OUT: x24

This yields an optimal value of -6.


For Problems 2.12 and 2.13 a solution is not provided as the tool does the check for you.

3
# PROBLEM 1 −− R i v e r C r o s s i n g
param a1 ; param b1 ;
param a2 ; param b2 ;
param v1 ; param v2 ; param v3 ;
param r 1 ; param r 2 ;

var x1 ;
var x2 ;

minimize time : s q r t ( ( a1−x1 ) ˆ 2 + ( b1−r 1 ) ˆ 2 ) / v1


+ s q r t ( ( x1−x2 ) ˆ 2 + ( r 1 − r 2 ) ˆ 2 ) / v2
+ s q r t ( ( x2−a2 ) ˆ 2 + ( r 2 − b2 ) ˆ 2 ) / v3 ;

data ;

param a1 := 60;
param b1 := 40;
param a2 := −50;
param b2 := −50;
param v1 := 10;
param v2 := 1.5;
param v3 := 7;
param r1 := 0;
param r2 := −30;

4
# PROBLEM 2 − 1 . 2 from LP Book
s e t FARE := {”Y” , ”B” , ”M” } ;
s e t ROUTE := {” ItNe ” , ”NeBo ” , ” ItBo ”} ;
param PRICE {ROUTE,FARE} ;
param CAPS {ROUTE,FARE} ;
var t i c k e t s { j i n ROUTE, i i n FARE} >= 0 , <= CAPS [ j , i ] ;

# Now f o r t h e LP
maximize p r o f i t : sum { i i n FARE, j i n ROUTE} PRICE [ j , i ] ∗ t i c k e t s [ j , i ] ;
s u b j e c t t o r c 1 : sum{ i i n FARE} ( t i c k e t s [ ” ItBo ” , i ] + t i c k e t s [ ” ItNe ” , i ] ) <= 3 0 ;
s u b j e c t t o r c 2 : sum{ i i n FARE} ( t i c k e t s [ ” ItBo ” , i ] + t i c k e t s [ ” NeBo ” , i ] ) <= 3 0 ;

# Now f o r t h e data . . .
data ;

param PRICE :=
[ ItNe , ∗ ] Y 300 B 220 M 100
[ NeBo , ∗ ] Y 160 B 130 M 80
[ ItBo , ∗ ] Y 360 B 280 M 1 4 0 ;
param CAPS :=
[ ItNe , ∗ ] Y 4 B 8 M 22
[ NeBo , ∗ ] Y 8 B 13 M 20
[ ItBo , ∗ ] Y 3 B 10 M 1 8 ;

You might also like