Package ca.nengo.model

Examples of ca.nengo.model.Origin


            for (UITermination terminationUI : nodeUI.getVisibleTerminations()) {
                if (terminationUI.getConnector() != null) {
                    UIOrigin originUI = terminationUI.getConnector().getOriginUI();

                    Termination termination = terminationUI.getModel();
                    Origin origin = originUI.getModel();

                    Projection projection = projectionMap.get(termination);
                    if (projection != null && projection.getOrigin() == origin) {
                        /*
                         * Projection already exists
                         */
                        projectionsToAdd.remove(projectionMap.get(termination));

                    } else {
                        projectionsToRemove.add(terminationUI.getConnector());
                    }
                }
            }
        }

        /*
         * Destroy unreferenced projections
         */
        for (UIProjection projectionUI : projectionsToRemove) {
            UITermination terminationUI = projectionUI.getTermination();

            projectionUI.destroy();
            if (!isFirstUpdate) {
                terminationUI.showPopupMessage("REMOVED Projection to "
                        + terminationUI.getNodeParent().getName() + "." + terminationUI.getName());
            }
        }

        /*
         * Construct projections
         */
        for (Projection projection : projectionsToAdd) {
            Origin origin = projection.getOrigin();
            Termination term = projection.getTermination();

            UINeoNode nodeOrigin = getUINode(origin.getNode());

            UINeoNode nodeTerm = getUINode(term.getNode());

            if (nodeOrigin != null && nodeTerm != null) {
                UIOrigin originUI = nodeOrigin.showOrigin(origin.getName());
                UITermination termUI = nodeTerm.showTermination(term.getName());

                originUI.connectTo(termUI, false);
                if (!isFirstUpdate) {
                    termUI.showPopupMessage("NEW Projection to " + termUI.getName() + "."
                            + getName());
                }
            } else {
                if (nodeOrigin == null) {
                    Util.Assert(false, "Could not find a Origin attached to a projection: "
                            + origin.getNode().getName());
                }
                if (nodeTerm == null) {
                    Util.Assert(false, "Could not find a Termination attached to a projection: "
                            + term.getNode().getName());
                }
View Full Code Here


    }
  }

  @Override
  protected Object createModel(ConfigResult configuredProperties, String uniqueName) throws ConfigException {
    Origin origin = null;

    try {
      origin = enfEnsembleParent.addDecodedOrigin(uniqueName, (Function[]) configuredProperties
          .getValue(pFunctions), "AXON");//(String) configuredProperties.getValue(pNodeOrigin));
View Full Code Here

  public UIOrigin addDecodedOrigin() {

    try {

      Origin origin = (Origin) ModelFactory.constructModel(this, new CDecodedOrigin(
          getModel()));
      UIOrigin originUI = UIOrigin.createOriginUI(this, origin);

      addWidget(originUI);
      showPopupMessage("New decoded ORIGIN added");
View Full Code Here

     * Assign the probe to a Origin / Termination
     */

    WorldObject probeHolder = null;

    Origin origin = null;
    try {
      origin = getModel().getOrigin(probeUI.getName());

    } catch (StructuralException e1) {
    }

    if (origin != null) {
      probeHolder = showOrigin(origin.getName());
    } else if (origin == null) {
      Termination term = null;
      try {
        term = getModel().getTermination(probeUI.getName());

View Full Code Here

    // Try to find if the origin has already been created
    originUI = (UIOrigin) getChild(originName, UIOrigin.class);
    if (originUI == null) {
      // try to create it
      try {
        Origin originModel = getModel().getOrigin(originName);
        if (originModel != null) {
          originUI = UIOrigin.createOriginUI(this, originModel);
          addWidget(originUI);
        } else {
          Util.Assert(false, "Could not find origin: " + originName);
View Full Code Here

  /**
   * @see ca.nengo.plot.Plotter#doPlot(ca.nengo.model.nef.NEFEnsemble, java.lang.String)
   */
  public void doPlot(NEFEnsemble ensemble, String name) {
    try {
      Origin o = ensemble.getOrigin(name);
     
      if ( !(o instanceof DecodedOrigin) ) {
        throw new RuntimeException("Can't plot origin error: Origin must be a DecodedOrigin");
      }
     
View Full Code Here

  /*
   * Test method for 'ca.nengo.model.impl.FunctionInput.getValues()'
   */
  public void testGetValues() throws StructuralException, SimulationException {
    FunctionInput input = new FunctionInput("test", new Function[]{new ConstantFunction(1, 1f), new ConstantFunction(1, 2f)}, Units.UNK);
    Origin origin = input.getOrigin(FunctionInput.ORIGIN_NAME);
    assertEquals(2, origin.getValues().getDimension());
    assertEquals(2, ((RealOutput) origin.getValues()).getValues().length);
   
    input.run(0f, 1f);
    assertEquals(2, origin.getValues().getDimension());
    assertEquals(2, ((RealOutput) origin.getValues()).getValues().length);
    float value = ((RealOutput) origin.getValues()).getValues()[0];
    assertTrue(value > .9f);
    value = ((RealOutput) origin.getValues()).getValues()[1];
    assertTrue(value > 1.9f);
  }
View Full Code Here

          inputOnGPU[i][j] = false;
        }
      }
     
      for (j = 0; j < networkArrayOrigins.length; j++) {
        Origin origin = networkArrayOrigins[j];
        boolean originWrapped = origin instanceof OriginWrapper;
        if(originWrapped)
          origin = ((OriginWrapper) origin).getWrappedOrigin();
       
        for (k = 0; k < myGPUProjections.length; k++) {
          Origin projectionOrigin = myGPUProjections[k].getOrigin();
          boolean projectionOriginWrapped = projectionOrigin instanceof OriginWrapper;
         
          if(projectionOriginWrapped)
            projectionOrigin = ((OriginWrapper) projectionOrigin).getWrappedOrigin();
         
          if (origin == projectionOrigin) {
            adjustedProjections[k][0] = i;
            adjustedProjections[k][1] = j;
          }
        }
       
        outputRequiredOnCPU[i][j] = (origin.getRequiredOnCPU() || requireAllOutputsOnCPU) ? 1 : 0;
       
        // even if its not explicitly required on the CPU, it might be implicitly
        // if it is attached to a projection whose termination is on the CPU
        if(outputRequiredOnCPU[i][j] == 0){
            for (k = 0; k < nonGPUProjections.length; k++) {
              Origin projectionOrigin = nonGPUProjections[k].getOrigin();
                        boolean projectionOriginWrapped = projectionOrigin instanceof OriginWrapper;
                       
                        if(projectionOriginWrapped)
                            projectionOrigin = ((OriginWrapper) projectionOrigin).getWrappedOrigin();
                   
View Full Code Here

      if(projectionTerminationWrapped)
        projectionTermination = ((TerminationWrapper) projectionTermination).getBaseTermination();
     
      Node terminationNode = projectionTermination.getNode();

      Origin projectionOrigin = proj.getOrigin();
      boolean projectionOriginWrapped = projectionOrigin instanceof OriginWrapper;
     
      if(projectionOriginWrapped)
        projectionOrigin = ((OriginWrapper) projectionOrigin).getWrappedOrigin();
     
      Node originNode = projectionOrigin.getNode();
     
      //Don't add self loops, since they are irrelevant to the min-cut computation
      //(and it allows us to use a SimpleWeightedGraph object).
      if(originNode != terminationNode){
        NodeVertex terminationVertex = nodeToVertex.get(terminationNode)
View Full Code Here

            + getNetwork().getName().replaceAll("\\p{Blank}|\\p{Punct}", ((Character) scriptData.get("spaceDelim")).toString());
     
      py.append(String.format("%1s.connect(", pythonNetworkName));
     
      StringBuilder originNodeFullName = new StringBuilder();
      Origin tempOrigin = myOrigin;

      while(tempOrigin instanceof OriginWrapper)
      {
        originNodeFullName.append(tempOrigin.getNode().getName() + ".");
        tempOrigin = ((OriginWrapper) tempOrigin).getWrappedOrigin();
      }
     
      StringBuilder terminationNodeFullName = new StringBuilder();
      Termination tempTermination = myTermination;

      while(tempTermination instanceof TerminationWrapper)
      {
        terminationNodeFullName.append(tempTermination.getNode().getName() + ".");
        tempTermination = ((TerminationWrapper) tempTermination).getWrappedTermination();
      }
     
      DecodedTermination dTermination;
      StringBuilder transformString = new StringBuilder();
     
      transformString.append('[');
      if(tempTermination instanceof DecodedTermination)
      {
        dTermination = (DecodedTermination) tempTermination;
        transformString.append(getTransformScript(dTermination, "transform = ".length()));
        terminationNodeFullName.append(tempTermination.getNode().getName());
      }
      else if(tempTermination instanceof EnsembleTermination &&
          tempTermination.getNode() instanceof NetworkArrayImpl)
      {
        terminationNodeFullName.deleteCharAt(terminationNodeFullName.length()-1);
       
        boolean first = true;
        for(Node node : tempTermination.getNode().getChildren())
        {
          if(first)
          {
            first = false;
          }else {
            transformString.append(",\n" + new String(new char["transform = ".length() + 1]).replace("\0", " "));
          }
         
          // this relies on the decoded terminations in the child nodes having the
          // same name as the ensemble termination that contains them
          try{
            dTermination = (DecodedTermination) node.getTermination(tempTermination.getName());
          }catch(Exception e){
            dTermination = null;
          }
         
          transformString.append(getTransformScript(dTermination, "transform = ".length() + 1));
        }
      }
      else
      {
        throw new ScriptGenException("Trying to generate script of non decoded termination which is not supported.");
      }

      transformString.append("]\n");
    
      // Now handle origin function if there is one
     
      String functionName = "";
      if(tempOrigin instanceof BasicOrigin && tempOrigin.getNode() instanceof FunctionInput)
      {
        originNodeFullName.append(tempOrigin.getNode().getName());
      }
      else
      {
        DecodedOrigin dOrigin;
        if(tempOrigin instanceof DecodedOrigin)
        {
          dOrigin = (DecodedOrigin) tempOrigin;
          originNodeFullName.append(tempOrigin.getNode().getName());
        }
        else if(tempOrigin instanceof NetworkArrayImpl.ArrayOrigin &&
            tempOrigin.getNode() instanceof NetworkArrayImpl)
        {
          originNodeFullName.deleteCharAt(originNodeFullName.length()-1);
          Node node = tempOrigin.getNode().getChildren()[0];
         
          try{
            dOrigin = (DecodedOrigin) node.getOrigin(tempOrigin.getName());
          }catch(StructuralException e){
            dOrigin = null;
          }
        }
        else
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.