Exemplo n.º 1
0
 private float[] getDynamicDecoder(int i, float input, float startTime, float endTime) {
   float[] result = myDecoders[i];
   if (mySTPDynamicsTemplate
       != null) { // TODO: could use a NullDynamics here instead of null (to allow nulling in
                  // config tree)
     // TODO: could recycle a mutable time series here to avoid object creation
     TimeSeries inputSeries =
         new TimeSeries1DImpl(
             new float[] {startTime, endTime}, new float[] {input, input}, Units.UNK);
     TimeSeries outputSeries = myIntegrator.integrate(mySTPDynamics[i], inputSeries);
     float scaleFactor = outputSeries.getValues()[outputSeries.getValues().length - 1][0];
     mySTPHistory[i] = scaleFactor;
     result = MU.prod(result, scaleFactor);
   }
   return result;
 }
Exemplo n.º 2
0
  /**
   * With this constructor the target is a signal over time rather than a function.
   *
   * @param node The parent Node
   * @param name As in other constructor
   * @param nodes As in other constructor
   * @param nodeOrigin Name of the Origin on each given node from which output is to be decoded
   * @param targetSignal Signal over time that this origin should produce.
   * @param approximator A LinearApproximator that can be used to approximate new signals as a
   *     weighted sum of the node outputs.
   */
  public DecodedOrigin(
      Node node,
      String name,
      Node[] nodes,
      String nodeOrigin,
      TimeSeries targetSignal,
      LinearApproximator approximator)
      throws StructuralException {

    myNode = node;
    myName = name;
    myNodes = nodes;
    myNodeOrigin = nodeOrigin;
    myFunctions = new FixedSignalFunction[targetSignal.getDimension()];
    for (int i = 0; i < targetSignal.getDimension(); i++) // these are only used in direct mode
    myFunctions[i] = new FixedSignalFunction(targetSignal.getValues(), i);
    myDecoders = findDecoders(nodes, MU.transpose(targetSignal.getValues()), approximator);
    myMode = SimulationMode.DEFAULT;
    myIntegrator = new EulerIntegrator(.001f);

    reset(false);
  }