001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.apache.commons.math4.legacy.ode;
019
020import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
021import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
022
023/**
024 * This interface allows users to add secondary differential equations to a primary
025 * set of differential equations.
026 * <p>
027 * In some cases users may need to integrate some problem-specific equations along
028 * with a primary set of differential equations. One example is optimal control where
029 * adjoined parameters linked to the minimized hamiltonian must be integrated.
030 * </p>
031 * <p>
032 * This interface allows users to add such equations to a primary set of {@link
033 * FirstOrderDifferentialEquations first order differential equations}
034 * thanks to the {@link
035 * ExpandableStatefulODE#addSecondaryEquations(SecondaryEquations)}
036 * method.
037 * </p>
038 * @see ExpandableStatefulODE
039 * @since 3.0
040 */
041public interface SecondaryEquations {
042
043    /** Get the dimension of the secondary state parameters.
044     * @return dimension of the secondary state parameters
045     */
046    int getDimension();
047
048    /** Compute the derivatives related to the secondary state parameters.
049     * @param t current value of the independent <I>time</I> variable
050     * @param primary array containing the current value of the primary state vector
051     * @param primaryDot array containing the derivative of the primary state vector
052     * @param secondary array containing the current value of the secondary state vector
053     * @param secondaryDot placeholder array where to put the derivative of the secondary state vector
054     * @exception MaxCountExceededException if the number of functions evaluations is exceeded
055     * @exception DimensionMismatchException if arrays dimensions do not match equations settings
056     */
057    void computeDerivatives(double t, double[] primary, double[] primaryDot,
058                            double[] secondary, double[] secondaryDot)
059        throws MaxCountExceededException, DimensionMismatchException;
060}