View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.math4.legacy.ode;
19  
20  import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
21  import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
22  
23  /**
24   * This interface allows users to add secondary differential equations to a primary
25   * set of differential equations.
26   * <p>
27   * In some cases users may need to integrate some problem-specific equations along
28   * with a primary set of differential equations. One example is optimal control where
29   * adjoined parameters linked to the minimized hamiltonian must be integrated.
30   * </p>
31   * <p>
32   * This interface allows users to add such equations to a primary set of {@link
33   * FirstOrderDifferentialEquations first order differential equations}
34   * thanks to the {@link
35   * ExpandableStatefulODE#addSecondaryEquations(SecondaryEquations)}
36   * method.
37   * </p>
38   * @see ExpandableStatefulODE
39   * @since 3.0
40   */
41  public interface SecondaryEquations {
42  
43      /** Get the dimension of the secondary state parameters.
44       * @return dimension of the secondary state parameters
45       */
46      int getDimension();
47  
48      /** Compute the derivatives related to the secondary state parameters.
49       * @param t current value of the independent <I>time</I> variable
50       * @param primary array containing the current value of the primary state vector
51       * @param primaryDot array containing the derivative of the primary state vector
52       * @param secondary array containing the current value of the secondary state vector
53       * @param secondaryDot placeholder array where to put the derivative of the secondary state vector
54       * @exception MaxCountExceededException if the number of functions evaluations is exceeded
55       * @exception DimensionMismatchException if arrays dimensions do not match equations settings
56       */
57      void computeDerivatives(double t, double[] primary, double[] primaryDot,
58                              double[] secondary, double[] secondaryDot)
59          throws MaxCountExceededException, DimensionMismatchException;
60  }