Program: 72551
Project: 72551
Buggy source:
/** 
 * Initialize this solver, associating it with the specified derivativeFunction object, which determines the number of state variables and input variables and provides a method for calculating the derivatives of the state variables. This method also initializes all input and state variables to zero. These can be the initialized to some other value by calling   {@link #setStateValue(int,double)} and{@link #setInputVariableModel(int,ModelPolynomial)}. The caller of this method should then, after setting state and input values, call   {@link #triggerQuantizationEvents(boolean)}with argument true. <p> This is a convenience method wrapping a sequence of calls to more detailed methods. </p>
 * @param derivativeFunction The object implementing thefunction that provides the derivatives for state variables that this solver is responsible for integrating. This object also provides a method specifying the number of state variables and the number of input variables.
 * @param startTime The start time for the solver.
 * @param maximumTime The maximum time for predicted events (e.g. the stoptime of the simulation). This may be infinite.
 * @param absoluteTolerance The absolute tolerance for all state variables(these can be modified later for individual states using  {@link #setQuantizationTolerance(int,double,double)}).
 * @param relativeTolerance The relative tolerance for all state variables(these can be modified later for individual states using  {@link #setQuantizationTolerance(int,double,double)}).
 * @param inputVariableOrder The order (the number of derivatives provided)for each input variable. If these differ by input variable, then the caller may later modify the input variable models by calling {@link QSSBase#setInputVariableModel(int,ModelPolynomial)}.
 */
public final void initialize(DerivativeFunction derivativeFunction,Time startTime,Time maximumTime,double absoluteTolerance,double relativeTolerance,int inputVariableOrder){
  initializeDerivativeFunction(derivativeFunction);
  initializeSimulationTime(startTime);
  setQuantizationEventTimeMaximum(maximumTime);
  for (int i=0; i < _stateCt; i++) {
    setStateValue(i,0.0);
    setQuantizationTolerance(0,absoluteTolerance,relativeTolerance);
  }
  for (int i=0; i < getInputVariableCount(); i++) {
    ModelPolynomial input=new ModelPolynomial(inputVariableOrder);
    input.claimWriteAccess();
    input.tMdl=startTime;
    setInputVariableModel(i,input);
  }
  final String failMsg=validate();
  assert(failMsg == null);
}

Fixed version (ground truth):
/** 
 * Initialize this solver, associating it with the specified derivativeFunction object, which determines the number of state variables and input variables and provides a method for calculating the derivatives of the state variables. This method also initializes all input and state variables to zero. These can be the initialized to some other value by calling   {@link #setStateValue(int,double)} and{@link #setInputVariableModel(int,ModelPolynomial)}. The caller of this method should then, after setting state and input values, call   {@link #triggerQuantizationEvents(boolean)}with argument true. <p> This is a convenience method wrapping a sequence of calls to more detailed methods. </p>
 * @param derivativeFunction The object implementing thefunction that provides the derivatives for state variables that this solver is responsible for integrating. This object also provides a method specifying the number of state variables and the number of input variables.
 * @param startTime The start time for the solver.
 * @param maximumTime The maximum time for predicted events (e.g. the stoptime of the simulation). This may be infinite.
 * @param absoluteTolerance The absolute tolerance for all state variables(these can be modified later for individual states using  {@link #setQuantizationTolerance(int,double,double)}).
 * @param relativeTolerance The relative tolerance for all state variables(these can be modified later for individual states using  {@link #setQuantizationTolerance(int,double,double)}).
 * @param inputVariableOrder The order (the number of derivatives provided)for each input variable. If these differ by input variable, then the caller may later modify the input variable models by calling {@link QSSBase#setInputVariableModel(int,ModelPolynomial)}.
 */
public final void initialize(DerivativeFunction derivativeFunction,Time startTime,Time maximumTime,double absoluteTolerance,double relativeTolerance,int inputVariableOrder){
  initializeDerivativeFunction(derivativeFunction);
  initializeSimulationTime(startTime);
  setQuantizationEventTimeMaximum(maximumTime);
  for (int i=0; i < _stateCt; i++) {
    setStateValue(i,0.0);
    setQuantizationTolerance(i,absoluteTolerance,relativeTolerance);
  }
  for (int i=0; i < getInputVariableCount(); i++) {
    ModelPolynomial input=new ModelPolynomial(inputVariableOrder);
    input.claimWriteAccess();
    input.tMdl=startTime;
    setInputVariableModel(i,input);
  }
  final String failMsg=validate();
  assert(failMsg == null);
}