HW2
1. Problem 3.1.1.a) and 3.1.1.b)
Use the Lagrange multiplier theorem to solve the following problems.
3.1.1.a)
,
Solution
Firstly, we need to define the Lagrange function:
Then we take the gradient with respect to x and set it to zero:
So we have:
Then we take the gradient with respect to and set it to zero:
Now we can substitute into the equation and then we have:
So:
Then we can substitute back into the equation of :
So the minimum point is:
Verification using the Second Order Sufficiency Condition in Proposition 3.2.1:
According to the Proposition 3.2.1, we need to check the Hessian matrix of the Lagrange function:
In which, we have:
So we have:
Let , we have .
So the tangent space is:
Then for all with , we have:
So the solution is strictly local minimum.
3.1.1.b)
,
Solution
Firstly, we need to define the Lagrange function:
Then we take the gradient with respect to x and set it to zero:
So we have:
Then we take the gradient with respect to and set it to zero:
Now we can substitute into the equation and then we have:
So:
Then we can substitute back into the equation of :
As we are picking the minimum, we should pick the negative one. So the minimum point is:
And the
Verification using the Second Order Sufficiency Condition in Proposition 3.2.1:
Check the Hessian matrix of the Lagrange function:
In which, we have:
So we have:
As , the tangent space is: \nabla h(x^_)' y = \sum\_{i=1}^n (x_i^_)y_i = 0
Then for all with , we have:
So the solution is strictly local minimum.
2. Industrial design
A cylindrical can is to hold 4 cubic inches of orange juice. The cost per square inch of constructing the metal top and bottom is twice the cost per square inch of constructing the cardboard side. What are the dimensions of the least expensive can?
Solution
First define the variables:
- :
radiusof the base of the can - :
heightof the can - :
costof the can - :
cost per square inchof constructing the cardboard side
Then we have the volume:
So the height is:
Total cost:
So to minimize the cost, we can just consider minimizing the , as is a constant:
Then we take the derivative and set it to zero:
So we have:
Verify the second derivative:
So it indeed is a local minimum.
Then we subtitute back into the equation of :
So the dimensions of the least expensive can are:
3. Duality
Prove that the following two problems are dual to each other:
Solution
As is equivalent to , we can introduce the dual variable and construct the Lagrange function:
And simplify it:
Then we can calculate the partial derivative with respect to :
If , as is unbounded, will not have a lower bound. So we have to set .
We have:
So the dual problem is to maximize subject to and .
The two problems are indeed dual to each other.
4. Problem 4.2.1 (a) (b) and (d)
(a)
Calculate the optimal solution and the Lagrange multiplier.
Solution
First construct the Lagrange function:
Then we take the gradient with respect to and set it to zero:
Then with respect to and set it to zero:
Then to :
We substitute into the equation of . So we get:
So the optimal solution and the Lagrange multiplier are:
(b)
For and calculate and compare the iterates of the quadratic penalty method with for all k, and the method of multipliers with .
Solution
First the augmented Lagrangian function is:
Quadratic penalty method:
As , we have:
Then we take the gradient with respect to and set it to zero:
Then :
- For , :
- For , :
- For , :
Method of multipliers:
Do partial derivative to and set it to zero:
Then :
Now we can start to iterate with the initial value of :
-
For , , :
-
For , , :
-
For , , :
So after all, we can say that the method of multipliers converges much faster than the quadratic penalty method.
5. Mathematical modeling for data mining
AMPL model file
set COUNTRIES;
param x1{COUNTRIES}; # Social setting
param x2{COUNTRIES}; # Effort
param y{COUNTRIES}; # Observed change
var a1; # Coefficient for x1
var a2; # Coefficient for x2
var b; # Intercept
minimize MSE:
sum{i in COUNTRIES} (y[i] - (a1 * x1[i] + a2 * x2[i] + b))^2;
# DATA SECTION
data;
set COUNTRIES := Bolivia Brazil Chile Colombia CostaRica Cuba DominicanRep Ecuador ElSalvador Guatemala Haiti Honduras Jamaica Mexico Nicaragua Panama Paraguay Peru TrinidadTobago Venezuela;
param x1 :=
Bolivia 46
Brazil 74
Chile 89
Colombia 77
CostaRica 84
Cuba 89
DominicanRep 68
Ecuador 70
ElSalvador 60
Guatemala 55
Haiti 35
Honduras 51
Jamaica 87
Mexico 83
Nicaragua 68
Panama 84
Paraguay 74
Peru 73
TrinidadTobago 84
Venezuela 91;
param x2 :=
Bolivia 0
Brazil 0
Chile 16
Colombia 16
CostaRica 21
Cuba 15
DominicanRep 14
Ecuador 6
ElSalvador 13
Guatemala 9
Haiti 3
Honduras 7
Jamaica 23
Mexico 4
Nicaragua 0
Panama 19
Paraguay 3
Peru 0
TrinidadTobago 15
Venezuela 7;
param y :=
Bolivia 1
Brazil 10
Chile 29
Colombia 25
CostaRica 29
Cuba 40
DominicanRep 21
Ecuador 0
ElSalvador 13
Guatemala 4
Haiti 0
Honduras 7
Jamaica 21
Mexico 9
Nicaragua 7
Panama 22
Paraguay 6
Peru 2
TrinidadTobago 29
Venezuela 11;
# display parameters after solving
solve;
display a1, a2, b, MSE;
print-out of the solution from the NEOS server
*************************************************************
NEOS Server Version 6.0
Job# : 15750375
Password : bTOlUkJR
User :
Solver : nco:MINOS:AMPL
Start : 2025-03-17 21:13:44
End : 2025-03-17 21:13:53
Host : prod-sub-1.neos-server.org
Disclaimer:
This information is provided without any express or
implied warranty. In particular, there is no warranty
of any kind concerning the fitness of this
information for any particular purpose.
Announcements:
*************************************************************
The license for this AMPL processor will expire in 13.9 days.
tions...
Executing AMPL.
processing data.
processing commands.
Executing on prod-exec-6.neos-server.org
3 variables, all nonlinear
0 constraints
1 nonlinear objective; 3 nonzeros.
MINOS 5.51: optimal solution found.
7 iterations, objective 694.0056746
Nonlin evals: obj = 16, grad = 15.
a1 = 0.270589
a2 = 0.967714
b = -14.4511
MSE = 694.006
model error table
| Country | x1 | x2 | y | Predicted ŷ | Error (y - ŷ) |
|---|---|---|---|---|---|
| Bolivia | 46 | 0 | 1 | -2.00 | 3.00 |
| Brazil | 74 | 0 | 10 | 5.57 | 4.43 |
| Chile | 89 | 16 | 29 | 25.11 | 3.89 |
| Colombia | 77 | 16 | 25 | 21.87 | 3.13 |
| CostaRica | 84 | 21 | 29 | 28.60 | 0.40 |
| Cuba | 89 | 15 | 40 | 24.15 | 15.85 |
| DominicanRep | 68 | 14 | 21 | 17.50 | 3.50 |
| Ecuador | 70 | 6 | 0 | 10.30 | -10.30 |
| ElSalvador | 60 | 13 | 13 | 14.36 | -1.36 |
| Guatemala | 55 | 9 | 4 | 9.14 | -5.14 |
| Haiti | 35 | 3 | 0 | -2.08 | 2.08 |
| Honduras | 51 | 7 | 7 | 6.12 | 0.88 |
| Jamaica | 87 | 23 | 21 | 31.35 | -10.35 |
| Mexico | 83 | 4 | 9 | 11.88 | -2.88 |
| Nicaragua | 68 | 0 | 7 | 3.95 | 3.05 |
| Panama | 84 | 19 | 22 | 26.66 | -4.66 |
| Paraguay | 74 | 3 | 6 | 8.48 | -2.48 |
| Peru | 73 | 0 | 2 | 5.30 | -3.30 |
| TrinidadTobago | 84 | 15 | 29 | 22.79 | 6.21 |
| Venezuela | 91 | 7 | 11 | 16.95 | -5.95 |
Discussion
- : Once the
social setting() increases by 1 unit, the predicted CBR change in the observed change is 0.270589. - : Once the
effort() increases by 1 unit, the predicted CBR change in the observed change is 0.967714, which is a much stronger effect than thesocial setting.
So we can say that the effort () shows a stronger relationship with CBR change.
- : As our MSE formula is , the average error is , which can be considered as a small error given ranges from 0 to 40.
- : But the negative intercept implies that without setting or effort, CBR change will be negative, which is unreasonable.
Overall, I would say that the model captures general trends well, but maybe shows poor performance in some extreme cases.