Package ca.nengo.model

Examples of ca.nengo.model.Origin


  /*
   * Test method for 'ca.bpt.cn.model.impl.NetworkImpl.getProjections()'
   */
  public void testGetProjections() throws StructuralException {
    Origin o1 = new ProjectionImplTest.MockOrigin("o1", 1);
    Origin o2 = new ProjectionImplTest.MockOrigin("o2", 1);
    Termination t1 = new ProjectionImplTest.MockTermination("t1", 1);
    Termination t2 = new ProjectionImplTest.MockTermination("t2", 1);
    Termination t3 = new ProjectionImplTest.MockTermination("t3", 2);

    myNetwork.addProjection(o1, t1);
View Full Code Here


     * @throws StructuralException if named Origin does not exist
     * @see ca.nengo.model.ExpandableNode#removeTermination(java.lang.String)
     */
    public synchronized Origin removeOrigin(String name) throws StructuralException {
        if (myOrigins.containsKey(name)) {
            Origin result = myOrigins.remove(name);

            fireVisibleChangeEvent();
            return result;
        }
        throw new StructuralException("Origin " + name + " does not exist");
View Full Code Here

* @author Bryan Tripp
*/
public class AbstractEnsembleTest extends TestCase {

  public void testFindCommon1DOrigins() {
    Origin one = new BasicOrigin(null, "2D", 2, Units.UNK);
    Origin two = new BasicOrigin(null, "unique", 1, Units.UNK);
    Origin three = new BasicOrigin(null, "shared1", 1, Units.UNK);
    Origin four = new BasicOrigin(null, "shared2", 1, Units.UNK);
   
    List<Origin> shared = new ArrayList<Origin>(3);
    shared.add(one);
    shared.add(three);
    shared.add(four);
   
    List<Origin> notshared = new ArrayList<Origin>(4);
    notshared.add(one);
    notshared.add(three);
    notshared.add(four);
    notshared.add(two);
   
    Node[] nodes = new Node[3];
    nodes[0] = new AbstractNode("a", shared, new ArrayList<Termination>(1)) {
      private static final long serialVersionUID = 1L;

      @Override
      public void run(float startTime, float endTime)
          throws SimulationException {}

      @Override
      public void reset(boolean randomize) {}

      public Node[] getChildren() {
        return new Node[0];
      }

      public String toScript(HashMap<String, Object> scriptData) throws ScriptGenException {
        return "";
      }};   
    nodes[1] = new AbstractNode("b", shared, new ArrayList<Termination>(1)) {
      private static final long serialVersionUID = 1L;

      @Override
      public void run(float startTime, float endTime)
          throws SimulationException {}

      @Override
      public void reset(boolean randomize) {}

      public Node[] getChildren() {
        return new Node[0];
      }

      public String toScript(HashMap<String, Object> scriptData) throws ScriptGenException {
        return "";
      }};   
    nodes[2] = new AbstractNode("c", notshared, new ArrayList<Termination>(1)) {
      private static final long serialVersionUID = 1L;

      @Override
      public void run(float startTime, float endTime)
          throws SimulationException {}

      @Override
      public void reset(boolean randomize) {}

      public Node[] getChildren() {
        return new Node[0];
      }

      public String toScript(HashMap<String, Object> scriptData) throws ScriptGenException {
        return "";
      }};
   
    List<String> origins = AbstractEnsemble.findCommon1DOrigins(nodes);
    assertEquals(2, origins.size());
    assertTrue(origins.contains(three.getName()));
    assertTrue(origins.contains(four.getName()));
  }
View Full Code Here

        result.myNodes[i] = (NEFEnsembleImpl) result.getNode(myNodes[i].getName());
      }
     
      // Clone array origins and ensemble terminations
      for (Origin exposedOrigin : getOrigins()) {
        Origin clonedOrigin = ((OriginWrapper) exposedOrigin).getBaseOrigin().clone(result);
        result.exposeOrigin(clonedOrigin, exposedOrigin.getName());
      }
      for (Termination exposedTermination : getTerminations()) {
        Termination clonedTermination = ((TerminationWrapper) exposedTermination).getBaseTermination().clone(result);
        result.exposeTermination(clonedTermination, exposedTermination.getName());
View Full Code Here

    public void setStates(float endTime) throws SimulationException {
        if (myLastPlasticityTime < endTime) {
            for (PlasticEnsembleTermination pet : myPlasticEnsembleTerminations.values()) {
                try {
                    Origin origin = this.getOrigin(pet.getOriginName());
                    pet.setOriginState(origin.getName(), origin.getValues(), endTime);
                    pet.setTerminationState(endTime);

                    if (pet instanceof ModulatedPlasticEnsembleTermination) {
                        DecodedTermination modTerm = (DecodedTermination)
                            this.getTermination(((ModulatedPlasticEnsembleTermination) pet).getModTermName());
View Full Code Here

   */
    @Override
    public TimeSeries getHistory(String stateName) throws SimulationException {
    TimeSeries result = null;

    Origin origin = myDecodedOrigins.get(stateName);
    DecodedTermination t = myDecodedTerminations.get(stateName);

    if (origin != null) {
      if (t != null)
        ourLogger.warn("Warning, probe set on ensemble with matching origin/termination names (\"" +
            stateName + "\"), probing origin by default");
     
        origin.setRequiredOnCPU(true);
      float[] vals = ((RealOutput) origin.getValues()).getValues();
      Units[] units = new Units[vals.length];
      for (int i = 0; i < vals.length; i++) {
        units[i] = origin.getValues().getUnits();
      }
      result = new TimeSeriesImpl(new float[]{myTime}, new float[][]{vals}, units);
    } else if (t != null) {
      result = t.getHistory(DecodedTermination.OUTPUT);
      } else if (t == null && stateName.endsWith(":STP")) {
View Full Code Here

    return result;
  }

  public void stopProbing(String stateName){
    Origin origin = myDecodedOrigins.get(stateName);
   
    if (origin != null) {
        origin.setRequiredOnCPU(false);
    }
  }
View Full Code Here

  /**
   * @see ca.nengo.model.Network#exposeOrigin(ca.nengo.model.Origin,
   *      java.lang.String)
   */
  public void exposeOrigin(Origin origin, String name) {
    Origin temp;

    temp = new OriginWrapper(this, origin, name);

    myExposedOrigins.put(name, temp );
    myExposedOriginNames.put(origin, name);
View Full Code Here

    //TODO: this works with a single Projection impl & no params; should add Projection.copy(Origin, Termination, Network)?
    result.myProjectionMap = new HashMap<Termination, Projection>(10);
    for (Projection oldProjection : getProjections()) {
      try {
        Origin newOrigin = result.getNode(oldProjection.getOrigin().getNode().getName())
          .getOrigin(oldProjection.getOrigin().getName());
        Termination newTermination = result.getNode(oldProjection.getTermination().getNode().getName())
          .getTermination(oldProjection.getTermination().getName());
        Projection newProjection = new ProjectionImpl(newOrigin, newTermination, result);
        result.myProjectionMap.put(newTermination, newProjection);
      } catch (StructuralException e) {
        throw new CloneNotSupportedException("Problem copying Projectio: " + e.getMessage());
      }
    }

    result.myExposedOrigins = new HashMap<String, Origin>(10);
    result.myExposedOriginNames = new HashMap<Origin, String>(10);
    result.OrderedExposedOrigins = new LinkedList <Origin> ();
    for (Origin exposed : getOrigins()) {
      String name = exposed.getName();
      Origin wrapped = ((OriginWrapper) exposed).getWrappedOrigin();
      try {
        // Check to see if referenced node is the network itself. If it is, handle the origin differently.
        if (wrapped.getNode().getName() != myName ) {
          Origin toExpose = result.getNode(wrapped.getNode().getName()).getOrigin(wrapped.getName());
          result.exposeOrigin(toExpose, name);
        }
      } catch (StructuralException e) {
        throw new CloneNotSupportedException("Problem exposing Origin: " + e.getMessage());
      }
View Full Code Here

TOP

Related Classes of ca.nengo.model.Origin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.