HybridGasAcceleration2.java
Created with JBuilder
import mads.core.*;
import java.util.*;
import mads.servicefunctions.*;


/**
 * <p><H1>Service Agents by Data Fitting</H1></p>
 *
 * <p><B>Sample project no. 12 </B><BR\> </p>
 * In some cases, data can be found just for a small number of years; one has to fit the 
 * data with some functions that fits (e.g. linear, logistic) and return this function. 
 * Which function best fits the data depends on the data type and distribution. One has to
 * do the fitting in an external software (e.g. Matlab, R, Origin) then use the obtained
 * vales in combination with a MADS service function template.<BR\>
 * <UL>
 *    <LI> The agent design is basically the same with the initially presented service agent
 *         All the action takes place in the <I>setServiceFunctionValues</I> function.<BR\>
 * </UL>
 * <p>This sample will show how one can create an agent starting with raw data. This data
 * is found in forecasts, usually in the form of Excel tables.
 */

public class Sample12_ServiceAgentsByDataFitting extends AServiceAgent
{
  // The name of the service
  public String getServiceName(){
     return "Gasoline Hybrid Acceleration";
  }

  // The description, including the measurement unit
  public String getDescription(){
    return "Acceleration (0-100km/h tim in sec) for a gasoline hybrid, similar to Toyota Prius";
  }

  // The time range, imposed by the data
  public String getTimeRange(){
    return "Any time range, but real data is only for 2000-2020. The rest is extension.";
  }

  // No parameters
  public String[] getParameters(){
    return new String[] {};
  }

  // The reference
  public String getReference(){
    return "Own research + MIT's On the Road in 2020 + GM2002 www.lbst.de/gm-wtw + TANK_TO_WHEELS Report, may 2006";
  }

  // No parameters, so nothing to do
  public String validateParameters(ArrayList parameterServiceFunctionsVector){
    return "";
  }

  // We now do the actual work. We first set the time interval this prediction is valid
  // and then, for each year, set the value.
  public void setServiceFunctionValues(ArrayList parameterServiceFunctionsVector, ServiceFunction myServiceFunction)
 {
   ServiceFunction sf = new LogisticServiceFunction(14.26, 8.69, 2004.67, 1.33169);
   for (int t = myServiceFunction.getBase(); t <= myServiceFunction.getBase() + myServiceFunction.getRange(); t++)
     myServiceFunction.setValue(t, sf.getValue(t));
 }

}



HybridGasAcceleration2.java
Created with JBuilder