'optimisation' is not defined

Asked by emmanuel.malherbe

Hi,

I've been using dolfin adjoint for 2 months now, and since 2 days I can't use my adjoint solver anymore. for that line:

optimisation.minimise(Jfunc, J, InitialConditionParameter(m), m, algorithm = "scipy.l_bfgs_b", pgtol=1e-04, bounds = (-1, 1), iprint = 1,maxfun=100)

Then I get the error:
"NameError: name 'optimisation' is not defined"

Please, can you tell me what to do? Do you think I should re install dolfin-adjoint? (I've tried to update it...)

Thanks a lot.

Emmanuel

Question information

Language:
English Edit question
Status:
Answered
For:
dolfin-adjoint Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was originally filed as bug #1044771.

Revision history for this message
emmanuel.malherbe (emmanuel-malherbe) said :
#1

Hi,

I've been using dolfin adjoint for 2 months now, and since 2 days I can't use my adjoint solver anymore. for that line:

optimisation.minimise(Jfunc, J, InitialConditionParameter(m), m, algorithm = "scipy.l_bfgs_b", pgtol=1e-04, bounds = (-1, 1), iprint = 1,maxfun=100)

Then I get the error:
"NameError: name 'optimisation' is not defined"

Please, can you tell me what to do? Do you think I should re install dolfin-adjoint? (I've tried to update it...)

Thanks a lot.

Emmanuel

Revision history for this message
Patrick Farrell (pefarrell) said :
#2

Hi Emmanuel,

Simon renamed all of the spellings to conform to US English conventions (against my better judgement).
So if you rename the call to

optimization.minimize

it should work.

Sorry for not letting you know -- I didn't know you're using it!

Patrick

Revision history for this message
Simon Funke (simon-funke) said :
#3

Hi Emmanuel,

there has been a few changes to the optimisation framework recently that have now been included to dolfin-adjoint but not yet documented (its on my TODO list).

Basically the new way of using the optimisation module is now the following:

First you need to run the forward model once. During this step dolfin-adjoint records all the equations that need to be solved within each optimisation iteration.

After that, execute the following lines of code to start the optimisation procedure:

  # Define your functional
  J = Functional(...)

  # Define the reduced functional
  rf = ReducedFunctional(J, InitialConditionParameter(m))

  # Run the optimisation problem with gradient tests and L-BFGS-B
  u_opt = minimize(rf, pgtol=1e-4, bounds = (-1, 1), iprint = 1)

Note that in particular you do not need you Jfunc definition any more.
If you are looking for an complete example, check out "tests/optimization/optimization.py" in the dolfin-adjoint repo.

Can you help with this problem?

Provide an answer of your own, or ask emmanuel.malherbe for more information if necessary.

To post a message you must log in.