280. Cheatsheet

281. Linear Programming

Function
Type
MethodExample
Maximization to
Minimization
max𝑓(𝑥)min𝑓(𝑥)max3𝑥+2𝑦min3𝑥2𝑦
Constraint
to
𝑔𝑖(𝑥)𝑏𝑖𝑔𝑖(𝑥)𝑏𝑖𝑥+𝑦5𝑥𝑦5
Equality Constraint𝑔𝑖(𝑥)=𝑏𝑖𝑔𝑖(𝑥)𝑏𝑖𝑔𝑖(𝑥)𝑏𝑖𝑥+𝑦=4𝑥+𝑦4𝑥+𝑦4
Slack Variable𝑥+𝑦6

Add slack variable 𝑠0:

𝑥+𝑦+𝑠=6

𝑠 is how much less is being used than the maximum limit of 6

Surplus Variable𝑥+𝑦6

Add slack variable 𝑠0:

𝑥+𝑦𝑠=6

𝑠 is the amount above the minimum required level 6

282. Integer Programming

Function
Type
MethodExample
At least 𝑘 of the items in 𝑆𝑖𝑆𝑥𝑖𝑘

Produce at least 3 products:

𝑖𝑆𝑥𝑖3
At most 𝑘 of the items in 𝑆𝑖𝑆𝑥𝑖𝑘

Open at most 2 facilities:

𝑖𝑆𝑥𝑖2
Exactly 𝑘 of the items in 𝑆𝑖𝑆𝑥𝑖=𝑘

Choose exactly one location:

𝑖𝑆𝑥𝑖=1
If 𝑥𝑎=1, then 𝑥𝑏=1𝑥𝑎𝑥𝑏If project A is done, project B must also be done
If 𝑥𝑎=1, then 𝑥𝑏=0𝑥𝑎+𝑥𝑏1Projects A and B are mutually exclusive
If 𝑥𝑎=1, then 𝑥𝑏+𝑥𝑐0𝑥𝑏+𝑥𝑐𝑀(1𝑥𝑎)If project A is selected, neither project B nor C can be selected
If 𝑥𝑗=0, then at least 𝑘
items in 𝑆 must be selected
𝑖𝑆𝑥𝑖𝑘(1𝑥𝑗)You have a main server represented by 𝑥𝑗. If it is down or not used (𝑥𝑗=0), then at least 𝑘 backup servers (in set 𝑆) must be activated
At least 𝑘 of 𝑚
constraints satisfied
𝑧𝑖={1if𝑔𝑖(𝑥)𝑏𝑖enforced0if𝑔𝑖(𝑥)𝑏𝑖relaxedfor𝑖=1,,𝑚𝑔𝑖(𝑥)𝑏𝑖𝑀𝑖(1𝑧𝑖)𝑖=1,,𝑚𝑖=1𝑚𝑧𝑖𝑘𝑀𝑖max𝑥(𝑔𝑖(𝑥)𝑏𝑖)Enforce any 𝑘 of the 𝑚 constraints by relaxing up to 𝑚𝑘 of them
Fixed (Setup) Costs𝑦={1ifis used0ifnot used𝑥0𝑥𝑀𝑦If facility is used (𝑦=1), then allow production up to 𝑀; else 𝑥=0
Balanced Flow𝑖𝑉𝑖𝑘𝑥𝑖𝑘=𝑑𝑘𝑖𝑉𝑖𝑘𝑥𝑗𝑘=𝑑𝑘Each node 𝑘 receives and sends exactly 𝑑𝑘 units of flow. If 𝑑𝑘=1, this is a TSP or assignment
Unbalanced Flow𝑖𝑉𝑖𝑘𝑥𝑖𝑘𝑖𝑉𝑖𝑘𝑥𝑗𝑘=𝑏𝑘

Each node 𝑘 has net inflow minus outflow equal to 𝑏𝑘:

  • 𝑏𝑘>0: demand
  • 𝑏𝑘<0: supply
  • 𝑏𝑘=0: transshipment
Subtours (MTZ)1𝑢𝑖𝑛1𝑖=2,,𝑛𝑢𝑖𝑢𝑗+(𝑛1)𝑥𝑖𝑗𝑛2𝑖𝑗,𝑖,𝑗{2,,𝑛}
Subtours (SEC)𝑖𝑆,𝑗𝑆𝑗𝑗𝑥𝑖𝑗|𝑆|1𝑆𝑉,|𝑆|2For every subset 𝑆 of the nodes 𝑉 that has at least 2 nodes, the total number of arcs (or paths) within that subset — from node 𝑖 to node 𝑗, where 𝑖𝑗 must be less than or equal to |𝑆|1

283. Non-Linear Programming

Function
Type
ExampleLinearization
Method
Example
Binary × Binary
Constraint
𝑧=𝑥𝑦𝑥,𝑦{0,1}𝑧𝑥𝑧𝑦𝑧𝑥+𝑦1𝑥{0,1}𝑧=1𝑥=𝑦=1
Binary × Continuous
Constraint
𝑧=𝑥𝑦𝑥{0,1}𝑦[𝐿,𝑈]𝑧𝑈𝑥𝑧𝐿𝑥𝑧𝑦𝐿(1𝑥)𝑧𝑦𝑈(1𝑥)
Continuous × Continuous
Constraint
𝑧=𝑥𝑦𝑥[𝐿𝑥,𝑈𝑥]𝑦[𝐿𝑦,𝑈𝑦]𝑧𝐿𝑥𝑦+𝐿𝑦𝑥𝐿𝑥𝐿𝑦𝑧𝑈𝑥𝑦+𝑈𝑦𝑥𝑈𝑥𝑈𝑦𝑧𝐿𝑥𝑦+𝑈𝑦𝑥𝐿𝑥𝑈𝑦𝑧𝑈𝑥𝑦+𝐿𝑦𝑥𝑈𝑥𝐿𝑦
Absolute Value𝑧=|𝑥|𝑧𝑥𝑧𝑥𝑧=|𝑥1𝑥2|𝑧𝑥1𝑥2𝑧𝑥2𝑥1
Max
Constraint
𝑦max(𝑥1,,𝑥𝑛)𝑦𝑥1𝑖=1,,𝑛𝑦+𝑥1+3max(𝑥1𝑥3,2𝑥2+4){𝑦+𝑥1+3𝑥1𝑥3𝑦+𝑥1+32𝑥2+4
Min
Constraint
𝑦min(𝑥1,,𝑥𝑛)𝑦𝑥1𝑖=1,,𝑛𝑦+𝑥1min(𝑥1𝑥3,2𝑥2+4,0){𝑦+𝑥1𝑥1𝑥3𝑦+𝑥12𝑥2+4𝑦+𝑥10
Max Min
Objective
maxmin(𝑥1,,𝑥𝑛)𝑦=min(𝑥1,,𝑥𝑛)𝑦𝑥𝑖𝑖=1,,𝑛
Min Max
Objective
minmax(𝑥1,,𝑥𝑛)𝑦=max(𝑥1,,𝑥𝑛)𝑦𝑥𝑖𝑖=1,,𝑛
Min Min
Objective
minmin(𝑥1,,𝑥𝑛)
Max Max
Objective
maxmax(𝑥1,,𝑥𝑛)

284. Algorithms

AlgorithmUpdate Rule
Gradient
Descent
𝑥𝑘+1=𝑥𝑘𝛼𝑓(𝑥𝑘)
Newton’s
Method
𝑥𝑘+1=𝑥𝑘[2𝑓(𝑘)]1𝑓(𝑥𝑘)

Newton’s Method

ApproximationTaylor
Expansion
Newton
Update
Linear (1D)𝑓(𝑥𝑘+1)𝑓(𝑥𝑘)+𝑓(𝑥𝑘)(𝑥𝑘+1𝑥𝑘)𝑥𝑘+1=𝑥𝑘𝑓(𝑥𝑘)𝑓(𝑥𝑘)
Linear (nD)𝑓(𝐱𝑘+1)𝑓(𝐱𝑘)+𝐻𝑘(𝐱𝑘+1𝐱𝑘)𝐱𝐤+1=𝐱𝑘𝐻𝑘1𝑓(𝐱𝑘)
Quadratic (1D)𝑓𝑄(𝑥)=𝑓(𝑥𝑘)+𝑓(𝑥𝑘)(𝑥𝑥𝑘)+12𝑓(𝑥𝑘)(𝑥𝑥𝑘)2𝑥𝑘+1=𝑥𝑘𝑓(𝑥𝑘)𝑓(𝑥𝑘)
Quadratic (nD)𝑚𝑘(𝐩)=𝑓(𝐱𝑘)+𝑓(𝐱𝑘)𝑇𝐩+12𝐩𝑇𝐻𝑘𝐩𝐩=𝐱𝐱𝑘𝐱𝐤+1=𝐱𝑘𝐻𝑘1𝑓(𝐱𝑘)