Menu

#57 Detection and continuation of extrema of user-defined monitor functions

---
open
nobody
None
2025-09-02
2024-03-07
No

Dear coco support team:

For a multi-segment implementation of a moving capsule driven by an internal oscillating mass, we wrote a code (in attachment) for numerical continuation of periodic solutions. We defined a monitor function (M_Pavg.m) that gives the average power consumption per period, and performed continuation with respect to the excitation frequency omega. The period of the solutions are 2 pi / omega in our case and the monitor function involves an integral.

Our goal is the following: during continuation detect the point where the average power achieves a local minimum (for instance via detecting a zero of the derivative of the power function with respect to the continuation parameter omega). Then, carry out a two-paramater continuation of this point with respect to the excitation amplitude and the frequency to obtain a locus of such local minima (holding the derivative above zero).

We think that the example 'int_optim' given in PO-Tutorial.pdf may be related to our goal, but we have difficulties adapting this code to our case. We would be grateful for your help in this matter.

Kind regards,
Joseph

1 Attachments

Discussion

  • Harry Dankowicz

    Harry Dankowicz - 2024-03-08

    Hi Joseph,

    This kind of functionality is made available in COCO using the staged construction of adjoint conditions. You can find several demos in the release that rely on this functionality., e.g., duffing_optim. The methodology is described in several publications, e.g., "Staged Construction of Adjoints for Constrained Optimization of Integro-Differential Boundary-Value Problems" and "Methods of continuation and their implementation in the COCO software platform with application to delay differential equations".

    Core support for this functionality is described in the CORE-Tutorial.pdf (sourceforge.net) file, as well as in the tutorial documentation for individual toolboxes.

    The int_optim demo shows a rather general construction of a particular kind of integral monitor function and its associated adjoint contributions. Importantly, it also supports remeshing of the underlying periodic orbit.

    The general principle is to detect a local minimum as a branch point, then branch switch to a branch along which only the Lagrange multipliers (adjoint variables) vary until the one corresponding to the monitor function equals 1. That locks you in on the minimum, so that if you keep that one fixed, you will follow a ridge of minima when releasing additional continuation parameters.

    At this time, I can confirm receipt, and will have a look at your code over the weekend.

    Best,

    Harry

     
  • Joseph Paez Chavez

    Thanks Harry, your advice in this matter is greatly appreciated.

     
  • Harry Dankowicz

    Harry Dankowicz - 2024-03-31

    Dear Joseph,

    I see that your problem involves use of the ode_isol2hspo constructor. To construct the corresponding adjoint contributions, use the adjt_isol2hspo constructor, as described in Section 12.3 of the PO_Tutorial.pdf (sourceforge.net) file.

    For the monitor function, I note that it uses the trapz function to perform numerical integration using the trapezoid rule. Since optimization will require derivatives of your monitor function, you will need to provide these explicitly, as first-order numerical differentiation is not supported for the adjoint constructors of the adjoint contributions (but is implemented for the Jacobians of the adjoint contributions). The int_optim demo uses Gaussian quadrature, and includes explicit derivatives.

    I recognize that the learning curve can be quite steep if you attempt to work problems of this kind without having first investigated simpler examples. I still recommend making reference to the journal papers cited above and the various demo examples in the tutorial documentation. I also encourage a staged approach, e.g., construction of the adjoint conditions for a simpler monitor function before trying to attack the full problem.

    Best,

    Harry

     
  • Joseph Paez Chavez

    Dear Harry, many thanks for looking into our code and your advice, we will try to adapt our code accordingly.

    Kind regards,
    Joseph

     
  • Joseph Paez Chavez

    Dear Harry, with the kind help of one of your former PhD students we were able to use the adjt_isol2hspo constructor to tackle the problem described in this post. However, during the continuation runs we get the following warning:

    Warning: Use of ADJT_BP2COLL is deprecated. Reset 'branch' property

    In adjt_BP2coll (line 45)
    In adjt_BP2bvp (line 58)
    In adjt_BP2hspo (line 53)

    And similarly for ADJT_BP2HSPO, ODE_BP2COLL and ODE_BP2BVP. Does the warning mean that the code may not run in future COCO releases? I would like to know if there is any way to avoid such warnings.

    Kind regards and thanks,
    Joseph

     
  • Harry Dankowicz

    Harry Dankowicz - 2025-09-02

    Thank you, Joseph, for the question.

    The most recent release of COCO provides new general-purpose support for generic branch switching (that was originally motivated by and is compatible also with analysis of symmetry-breaking bifurcations in dynamical systems with symmetries). As a result, constructors of the form ===BP2TYPE have all been deprecated in favor of the corresponding ===TYPE2TYPE constructor and the assignment of 'switch' to the 'branch' property of the 'cont' settings.

    You can find examples of this in the tutorial documentation and demos. For example, in EP_Tutorial.pdf on pages 10, 14, 26, and as described on page 33; in COLL-Tutorial.pdf on page 33 and as described on page 43; in PO-Tutorial.pdf on pages 14 and 38, and as described on page 51; in CORE-Tutorial.pdf on pages 8, 13, and 20; and in GettingStartedwithCOCO.pdf on pages 5, 7, 26.

    This change eliminates the need for separate constructors for generic branch switching.

    I hope that helps.

    /Harry

     
  • Joseph Paez Chavez

    Dear Harry, many thanks for the soon reply, the code have been now adapted according to your advice.

    Kind regards and thanks,
    Joseph

     

Log in to post a comment.

MongoDB Logo MongoDB