/**
  * Method for calculating the returns on a given rate path, via the definition for the
  * instantaneous compounded return. u_i = \ln{\frac{S_i}{S_{i-1}}}
  *
  * @return the return, as defined.
  * @exception DemoException thrown if there is a problem with the calculation.
  */
 public ReturnPath getReturnCompounded() throws DemoException {
   if (pathValue == null || nAcceptedPathValue == 0) {
     throw new DemoException("The Rate Path has not been defined!");
   }
   double[] returnPathValue = new double[nAcceptedPathValue];
   returnPathValue[0] = 0.0;
   try {
     for (int i = 1; i < nAcceptedPathValue; i++) {
       returnPathValue[i] = Math.log(pathValue[i] / pathValue[i - 1]);
     }
   } catch (ArithmeticException aex) {
     throw new DemoException("Error in getReturnLogarithm:" + aex.toString());
   }
   ReturnPath rPath = new ReturnPath(returnPathValue, nAcceptedPathValue, ReturnPath.COMPOUNDED);
   //
   // Copy the PathId information to the ReturnPath object.
   rPath.copyInstanceVariables(this);
   rPath.estimatePath();
   return (rPath);
 }
  public void meetInto(ReturnPath fact, Edge edge, ReturnPath result)
      throws DataflowAnalysisException {
    switch (edge.getType()) {
      case UNHANDLED_EXCEPTION_EDGE:
        fact = new ReturnPath(ReturnPath.UE);
        break;
      case EXIT_EDGE:
        fact = new ReturnPath(ReturnPath.EXIT);
        break;
    }

    result.mergeWith(fact);
  }
 /**
  * Method for copying the suitable instance variable from a <code>ReturnPath</code> object.
  *
  * @param obj Object used to define the instance variables which should be carried over to this
  *     object.
  * @exception DemoException thrown if there is a problem accessing the instance variables from the
  *     target objetct.
  */
 private void copyInstanceVariables(ReturnPath obj) throws DemoException {
   //
   // Instance variables defined in the PathId object.
   set_name(obj.get_name());
   set_startDate(obj.get_startDate());
   set_endDate(obj.get_endDate());
   set_dTime(obj.get_dTime());
   //
   // Instance variables defined in this object.
   this.returnDefinition = obj.get_returnDefinition();
   this.expectedReturnRate = obj.get_expectedReturnRate();
   this.volatility = obj.get_volatility();
 }
 public boolean same(ReturnPath fact1, ReturnPath fact2) {
   return fact1.sameAs(fact2);
 }
 public boolean isTop(ReturnPath fact) {
   return fact.getKind() == ReturnPath.TOP;
 }
 public void makeFactTop(ReturnPath fact) {
   fact.setKind(ReturnPath.TOP);
 }
 public void initEntryFact(ReturnPath fact) {
   fact.setKind(ReturnPath.RETURNS);
 }
 public void copy(ReturnPath source, ReturnPath dest) {
   dest.copyFrom(source);
 }