6.2. Assignment (lab06)#

This ungraded assignment is a collection of 10 engineering problems that can be solved by optimization. In order to understand and solve the exercises, and more generally to gain the maximum benefit from this assignment, it is highly recommended that you revise Chapter 4 and Chapter 5.

6.2.1. Content#

Activity

Topic

Difficulty

Quiz 1

Travel time

Easy

Quiz 2

Facility location

Easy

Quiz 3

Area fencing

Easy

Quiz 4

Topless box

Easy

Quiz 5

Distance between polygons

Medium

Quiz 6

Shortest path

Medium

Quiz 7

Trilateration

Medium

Quiz 8

Resection

Hard

Quiz 9

Inscribed circle

Hard

Quiz 10

Optimal trajectory

Hard

6.2.2. Required packages#

For this assignment, you need to import the following packages.

  • Numpy - The library for scientific computing in Python.

  • Matplotlib - The library for plotting graphs in Python.

  • Autograd - The library for automatic differentiation of Numpy code.

Installation: Open the terminal (‘Anaconda Prompt’ on Windows) and execute the following command.

pip install autograd

Add the flag --user for a local installation (only if you are not the admin).

6.2.3. Autograd caveats#

Not all the NumPy features can be used with Autograd. Here is the list of operations that you must avoid inside your cost functions.

  • Don’t use assignment to arrays A[0,0] = x, A[:,1] = y, …

    • Create new arrays through vectorized operations!

  • Don’t create lists w = [x, y]

    • Create new arrays: w = np.array([x, y])

  • Don’t implicitly cast lists to arrays A = np.sum([x, y])

    • Use explicit casts: A = np.sum(np.array([x, y]))

  • Don’t use in-place operations such as a += b

    • Use binary opertions: a = a + b

  • Don’t use the operation A.dot(B)

    • Use the operation: A @ B

  • Never execute the line import numpy as np

    • Use the line: import autograd.numpy as np