ΘρϵηΠατπ

Dual & Simplex
Consider the following linear program: max  4x1+x2+5x3+3x4subject to  x1x2x3+3x41 5x1+x2+3x3+8x455 x1+2x2+3x35x43 x1,x2,x3,x40
  • Write the dual of this linear program. Show your steps.
  • Use the simplex algorithm to solve the original linear program. Show each step of the simplex algorithm as well as the final result.

When constructing the dual, we want to try to find some upper bound on the maximization goal, we do this by multiplying all of our equations by positive constants y1,y2,y30, we obtain y1(x1x2x3+3x4)y1y2(5x1+x2+3x3+8x4)y255y3(x1+2x2+3x35x4)y33 by summing all the equations we obtain the following equation: x1(y1+5y2y3)+x2(y1+y2+2y3)+x3(y1+3y2+3y3)+x4(3y1+8y25y3)y1+55y2+3y3 We see that the LHS is upperbounded by the RHS, we know that by minimizing the upper-bound to be as small as possible this will force the solution to the dual to be equal to the solution of the primal, so we must minimize : y1+55y2+3y3 under the constraints:  y1+5y2y34 y1+y2+2y31 y1+3y2+3y35 3y1+8y25y33 this is the dual.


Now we want to use the simplex algorithm to solve the given question. Next we re-write our question in the slack form, which is the following:

z:=4x1+x2+5x3+3x4x5:=1x1+x2+x33x4(α)x6:=555x1x23x38x4(β)x7:=3+x12x23x3+5x4(γ) x1,x2,x3,x4,x5,x6,x70

The first stage of the simplex algorithm is to note that xi=0 is a feasible solution, because 1,55,3>0 and is a vertex of our polytope. Since we already have a vertex let's move to another vertex to increase our objective value z. Right now we know that xi=0, so increase z we may increase any such xi that has a positive coefficient, for example we pick x1 and call it our "entering variable".

Given this choice, let's see how much we can increase the value of x1, recall that we already know that x2,x3,x4=0, by α we obtain the equation x5=1x1x1=1x51, by β we know 5x155x111 and through γ we have that 03+x13x3, which doesn't add any new information. So the tightest obstacle is the one produced by α which states that x11. Therefore we can safely increment x1=1, instead of actually setting this value, we instead do something different, we instead take equation α and then solve the tighest obstacle for the nonbasic varaible x1=1+x2+x33x4x5 Here we say that x1 is the "entering varaible" because it has entered the LHS, and we say that x5 is an "leaving variable" because x5 has left the LHS. Now what we do is that we subsitute this value of x1 in all the other parts of the slack form: z:=4(1+x2+x33x4x5)+x2+5x3+3x4=4+5x2+9x39x4x5x1=1+x2+x33x4x5(α)x6:=555(1+x2+x33x4x5)x23x38x4=506x28x3+7x4+5x5(β)x7:=3+(1+x2+x33x4x5)2x23x3+5x4=4x22x3+2x4x5(γ) At this point we see that after one interation we've increased z=0 to z=4, now we repeat this process. So we pick x2 since it has a positive coefficient, then we can look at the rest of the constraints: z=4+5x2+9x39x4x5x1=1+x2+x33x4x5(α)x6=506x28x3+7x4+5x5(β)x7=4x22x3+2x4x5(γ) We see that α yields 01+x21x2 , β: 0506x2x212, γ: x24, the tighest obstcale is given by γ with x24 by re-arranging γ we obtain that x2=42x3+2x4x5x7 we now substitute this in to obtain z=4+5(42x3+2x4x5x7)+9x39x4x5=24x3+x46x55x7x1=1+(42x3+2x4x5x7)+x33x4x5(α)=5x3x42x5x7x6=506(42x3+2x4x5x7)8x3+7x4+5x5(β)=26+4x35x4+11x5+6x7x2=42x3+2x4x5x7(γ) At this point there is one last varaible with a positive coefficient in z's equation which is x4, so we look at the equations again to find the tighest obstacle: z=24x3+x46x55x7x1=5x3x42x5x7(α)x6=26+4x35x4+11x5+6x7(β)x2=42x3+2x4x5x7(γ)

  • α: x45
  • β: 5x426x4265
  • γ: 04+2x42x4

We know that 5=255<265 so then α produces the tightest constraint, solving for x4 in that equation yields x4=5x1x32x5x7 now we can substitute that value everwhere: z=24x3+(5x1x32x5x7)6x55x7=29x12x38x56x7x4=5x1x32x5x7(α)x6=26+4x35(5x1x32x5x7)+11x5+6x7(β)=1+5x1+9x3+22x5+11x7x2=42x3+2(5x1x32x5x7)x5x7(γ)=142x14x36x53x7 which we can concicely write as z=29x12x38x56x7x4=5x1x32x5x7(α)x6=1+5x1+9x3+22x5+11x7(β)x2=142x14x36x53x7(γ) At this point we can see that there are no non-basic varaibles with positive coefficient and so our answer is given by x1,x3,x5,x7=0 and x4=5,x6=1,x2=14 which gives optimal value z=29.

Largest Disk in a Polygon

A convex polygon P in 2 can be specified as the intersection of halfspaces of the form aix+biyci. Give a linear program that finds a circle of maximum radius that lies within P.

Let the i-th side of P lie on a line i with equation y=aix+bi,i=1,2,...,n, and let us choose the numbering of the sides in such a way that the first, second, up to the k-th side bound P from below, while the (k+1)-st through nth side bound it from above. Define your own variables if needed.

You can assume that it is always feasible to have the circle in the region enclosed by the lines, i.e. the polygon enclosed by the lines are given to you for free, so you don't have to use linear constraints to describe the polygon or figure out which half-space each line specifies. It is "that" polygon given to you

Suppose that the center point of some disk is given by C=(c1,c2), and that it has radius r>0, if this disk is to lie within the polygon generated by the lines, then for any specific line inequality, every point in the disk must lie with

An equivalent criterion for this to be true is the simple requirement that the closest point on the line to be distance at least r from C. If this holds true for every such line, then we know that the disk centered at C with radius r must be within the polygon.

We'll now focus on how we can determine if the closest point on any given line is at least distance r away from C.

We are interested in Z which represents the distance from C to the closest point on the line, for now just observe that there is a similar triangle hidden in here:

Since the two triangles are similar then we have that c2ac1+bZ=xz We also know some more information about this smaller triangle. Since it sits on the line y=ax+b then we know that the left side of this triangle is equal to za, and therefore z2+(az)2=x2x=za2+1 so that xz=a2+1, and therefore c2ac1+bZ=a2+1Z=c2ac1+ba2+1 With respect to our original goal, we would require that Zr.

Let's take a moment to note that we've just dealt with a line which would bound the disk below, if the line were to bound the disk by above then the value c2ac1+b would be a negative value, so that we would require Zr.

With all that said we maximize r subject to c2aic1biai2+1r for i[1,k] and c2ajc1bjaj2+1r for j[k+1,,n], where c1,c2, and r>0

Which yields a linear program, to which the solution produces a disk of maximum radius completely inside the polygon, as needed.

Simple Scheduling with Prerequisites

You are given n jobs with a list of durations d1,d2,dn. For every pair of jobs (i,j) you are given a boolean pi,j such that if it is true then job i must finish before job j can begin, meaning that job i is a pre-requisite for job j

Your goal is to find non-negative start times s1,,sn for the jobs such that the total time of all jobs is minimized while ensuring that the prerequisite constrains are met. Write a linear program to solve this problem.

For any job i we note that it's finishing time is si+di, the total duration for all jobs to be completed is simply T:=max({si+di:i[1,,n]}), but this is not a linear combination of our variables so instead of defining it, we simply declare it as a variable T and assert that T>0 and add n constraints of the form T>si+di

We also need to enforce certain constraints, which is to say that for any pi,j which is true we add the following inequality: si+disj which says that the finishing time of job i comes before the start time of job j.

We also have si>0 for all i[1,,n], and now along with these contraints we minimize T which defines our linear programming problem.

Binary Integer Linear Program
An optimization problem with a linear objective, linear constraints and each variable taking the value 0 or 1.
Logical Operators
Suppose you are writing down a binary integer linear program. Three of the binary variables in your program are x,y,z{0,1}, show how to encode the following relations between x,y,z using linear constraints:
  • z=xy
  • z=xy
  • z=¬x
where 0,1 represent false and true respectively.

For logical and we require both to be true, which means that x=1 and y=1 and in that case we require that z=1 in any other case we need that z=0. It can be seen that these constraints are equivalent to z=min(x,y) under this view it's simpler to derive constraints. Firstly the minimum must be smaller than the two input values: zx and zy note that this is not enough still because if x,y=1 then we can still pick z=0 and things are satisfied, so we need to enforce a lower bound on z, to construct this lower bound, we'll consider a few cases.

  • x,y=1, we require that z1
  • if x=1,y=0, x=0,y=1 or x=0,y=0, our initial constraints automatically force z=0 so no extra constraints are required.

From the above, we can throw in the constraint that zx+y1 which enforces z1 when x,y=1 and in the other cases it either enforces z0 or z1 which add no information since we know that z{0,1}


For logical or, we require that at least one of x,y is equal to 1. Which means their sum is at least one, so we encode that with we see that this is equivalent to z=max(x,y) but that max is not a linear constraint, therefore we have to take a similar approach as above, similarly we require that zx and zy symetrically when x,y=0 then z=0 is a possibility so we need to put an upper bound on z and we'll just note that zx+y works


Finally for z=¬x we need to take 10 and 01 which can be done with z=x1 note that equality can be represented by two opposite inequalities.

Cargo Plane
A cargo plane can carry a maximum weight of 100 tons and a maximum volume of 60 cubic meters. There are three materials to be transported, and the cargo company may choose to carry any amount of each, up to the maximum available limits given below.
  • Material 1 has density 2 tons/cubic meter, maximum available amount 40 cubic meters, and revenue $1,000 per cubic meter.
  • Material 2 has density 1 ton/cubic meter, maximum available amount 30 cubic meters, and revenue $1,200 per cubic meter.
  • Material 3 has density 3 tons/cubic meter, maximum available amount 20 cubic meters, and revenue $12,000 per cubic meter.

  • Write a linear program in standard form that optimizes revenue within the constraints.
  • Explain what the dual of a linear program is and why one may wish to solve the dual formulation rather than the primal formulation.
  • Write the dual formulation of the program in part (a). The result does not need to be in standard form for the dual in that you are not responsible for remembering the direction of inequalities in the standard form for dual formulations.

Let m1,m2,m3 denote how many cubic meters of each material there are where mi0, we'd like to maximize our profit which is given by the equation 1000m1+1200m2+12000m3

Our cargo plane can carry a maximum weight of 100 tons, since each material has a different density this means that 2m1+m2+3m3100

It can store a maximum volume of 60 cubic meters, meaning that m1+m2+m360

We also know that there are only limited amounts of each material, we have that: m140 and m230 and m320


If someone claims they have an algorithm to solve a linear program and give you a maximum value, you can only check if it meets the constraints, but you can't be sure it's the best value. The dual of a linear program aims to minimize with respect to an upper bound of the original question. If a solution to both the primal and dual linear programs yields the same objective values, it's maximal. This dual verification serves as a certificate to confirm if a given value is the maximum.

It may turn out that the dual problem may be easier or quicker to solve as compared to the primal problem, this is one reason why one may prefer the dual over the primal.


To obtain the dual we take our original primal and introduce variables y1,y2,y3,y4,y5, for each inequality in the primal, then we multiply the i-th inequality by yi, then we sum all the inequalities to obtain a master sum: m1(y1+2y2+y3)+m2(y1+y2+y4)+m3(y1+3y2+y5)60y1+100y2+40y3+30y4+20y5 We can see that this inequality is implied by the primal, and what we'd like to do is to choose values for yi which make the upper bound as small as possible, also we'd like to make sure that 1000m1+1200m2+12000m3m1(y1+2y2+y3)+m2(y1+y2+y4)+m3(y1+3y2+y5) by doing this it makes sure that the upper bound will be an upper bound of what we were maximizing so that the primal doesn't find some smaller solution. With all that said the primal is thus given by minimizing 60y1+100y2+40y3+30y4+20y5 such that y1+2y2+y31000y1+y2+y41200y1+3y2+y512000