Skip to content

BUG: IPOPTSolver not working in the 2025.10 version #228

Description

@diego-hayashi

Describe the bug
IPOPTSolver not working in the 2025.10 version.

Steps to Reproduce
I edited the code from the Firedrake Jupyter notebook about PDE-constrained optimization in order to test this.

The mesh stokes-control.msh was downloaded according to the instructions from the notebook by running:

curl -O https://raw.githubusercontent.com/firedrakeproject/notebooks/refs/heads/main/stokes-control.msh

Steps to reproduce the behavior:

  1. In order to simplify, I copied only the parts of the notebook that mattered below:
from firedrake import *
from firedrake.adjoint import *
continue_annotation()
mesh = Mesh("stokes-control.msh") # curl -O https://raw.githubusercontent.com/firedrakeproject/notebooks/refs/heads/main/stokes-control.msh
V = VectorFunctionSpace(mesh, "Lagrange", 2)
Q = FunctionSpace(mesh, "Lagrange", 1)
W = V*Q
v, q = TestFunctions(W)
u, p = TrialFunctions(W)
nu = Constant(1) 
x, y = SpatialCoordinate(mesh)
u_inflow = as_vector([y*(10-y)/25.0, 0])
noslip = DirichletBC(W.sub(0), (0, 0), (3, 5))
inflow = DirichletBC(W.sub(0), u_inflow, 1)
static_bcs = [inflow, noslip]
g = Function(V, name="Control")
controlled_bcs = [DirichletBC(W.sub(0), g, 4)]
bcs = static_bcs + controlled_bcs
a = nu*inner(grad(u), grad(v))*dx - inner(p, div(v))*dx - inner(q, div(u))*dx
L = Constant(0)*q*dx
w = Function(W)
solve(a == L, w, bcs=bcs)
u, p = split(w)
alpha = Constant(10)
J = assemble(1./2*inner(grad(u), grad(u))*dx + alpha/2*inner(g, g)*ds(4))
m = Control(g)
Jhat = ReducedFunctional(J, m)
get_working_tape().progress_bar = ProgressBar

Following this part, the code originally used g_opt = minimize(Jhat) (i.e., SciPy), which I changed to IPOPT:

problem = MinimizationProblem(Jhat)
parameters = {'maximum_iterations': 10}
solver = IPOPTSolver(problem, parameters = parameters)
g_opt = solver.solve()
  1. The code was run with the default python command in a terminal:
python stokes-control.py

Expected behavior
The code should have run normally in the IPOPT case; however, it returned an error.

Error message

Traceback (most recent call last):
  File "stokes-control.py", line 39, in <module>
    g_opt = solver.solve()
            ^^^^^^^^^^^^^^
  File "/opt/Firedrake/2025.10.0/lib/python3.12/site-packages/pyadjoint/optimization/ipopt_solver.py", line 199, in solve
    results = self.ipopt_problem.solve(guess)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "cyipopt/cython/ipopt_wrapper.pyx", line 730, in ipopt_wrapper.Problem.solve
  File "cyipopt/cython/ipopt_wrapper.pyx", line 976, in ipopt_wrapper.gradient_cb
  File "/usr/lib/python3.12/contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
TypeError: ReducedFunctionalNumPy.derivative() got an unexpected keyword argument 'forget'

Environment:

  • OS: Linux (Ubuntu 24.04.3 LTS)
  • Python version: 3.12.3
  • Versions: Firedrake 2025.10, pyadjoint 2025.10, cyipopt 1.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions