Section 6 - Eg 1 - Walkway of Fixed Width Given Finite Material - Intro to NLP

That is, there is a space of given dimensions. Now, build a walkway around it such that the space (linear) between the empty-space-edge and the walkway is constant and using only the available material to build the walkway.

Sounds like something we might have done in differential calculus class ages ago.

But, what makes this one different is that the Objective function involves w*l = meaning - it's non-linear.

He's good at solving optimization problems, but a very poor (undisciplined) coder. Doesn't think twice about sprinkling magic constants throughout the code :(

!pip install pyomo

!wget -N -q "https://ampl.com/dl/open/ipopt/ipopt-linux64.zip"

!unzip -o -q ipopt-linux64


Solver = SolverFactory( 'ipopt', executable = '/content/ipopt')

OK, the code nails it easily, and that's when (checking the width thing), I realized that this one can be done on the back of an envelope. 

And, then, I saw that it can't be - because he (they, maybe? Poler and Diaz-Madronero) did such a poor job in problem description and elucidation. A simple 3D sketch in 10 seconds would have helped.

Turns out, you don't even need calculus in this case. Just assume you use all the material - why wouldn't you?

2x1 + 2x2 - 56 = 250 (minus 56? Because you put a handrail around that "empty space" 😊

Then, the constant width gives you a 2nd equation and they give you x1 = 44.5 and you're done. How lame!


Comments

Popular posts from this blog

Section 5 Challenge Problem: Traveling Salesman

Integer Programming (Section 5) Introduces a Nice (Big "em") Coding Trick