Announcement: CASHOCS - A computational, adjoint-based shape optimization and optimal control software

Hello everyone,

I wanted to make a small announcement regarding a package I released recently: CASHOCS.
CASHOCS is a package based on FEniCS, designed to solve shape optimization and optimal control problems in an automated fashion. In that sense, it is somewhat similar to dolfin-adjoint, but follows more of a first optimize, then discretize approach, as it only uses automatic differentiation to derive the adjoint and gradient equations. The user can then specify how each of these should be solved, and can, e.g., even use different finite element approximations for the state and adjoint systems.

You can find the software on github:

and on pypi:

and the documentation is available here:

Finally, let me remark that this project might be still be of interest for you, even if you do not want to solve any PDE constrained optimization problems: It automates the mesh conversion from gmsh to fenics, including physical groups etc. If you have a mesh file with physical tags, say mesh.msh its usage is as simple as calling

cashocs-convert mesh.msh mesh.xdmf

from the command line. And in your script, you can import this mesh using

import cashocs
mesh, subdomains, boundaries, dx, ds, dS = cashocs.import_mesh(mesh.xdmf)

and it directly generates the MeshFunctions for the subdomains and boundaries, and initializes the corresponding measures, too.

I hope you find this package helpful, and if you have any questions, suggestions, or feedback, please contact me.


Very interesting. Does CASHOCS assume there is always a variational problem to be solved?

For instance, in some time dependent control problems one could want to use an explicit time stepping scheme, where each y[k] is an explicit expression evaluated from previous time steps k-1, k-2, … Can I do that and still optimize with CASHOCS?

Yes, cashocs assumes that the PDE constraint is given in a variational formulation. You can still do time-dependent problems, by formulating them as sequence of one-way coupled stationary problems, like done here:
This code can be easily adapted to use the explicit Euler scheme, so this might be what you want to do.

In case you have an ODE constraint, where you actually do not want to have a variational problem, this will be trickier, but might (depending on your problem) still be doable with cashocs, but it might be a bit hacky then.