Optimizing State Value at Single Point in Time

Dear @nwycoff,

The reason that J = (v(6)-5)**2*dx + 0.001*in_weight**2*dx doesn’t work, is that v(6) and 5 are floats and therefore has no integration domain.

Recently, we added support of point evaluation to pyadjoint. For your example,
J = (v(numpy.array([6]))-5)**2 + assemble(0.001*in_weight**2*dx)
Does the trick.
To visualize the solution:

import matplotlib.pyplot as plt
plot(v.block_variable.saved_output)
plt.grid()
print("Actual value: ", v.block_variable.saved_output(6))
plt.savefig("v.png")