示例#1
0
 @Override
 public List<PotentialConsumer> getPotentialConsumers() {
   List<PotentialConsumer> returnList = new ArrayList<PotentialConsumer>();
   for (AttributeType type : getVisibleConsumerTypes()) {
     if (type.getTypeName().startsWith("Neuron ")) {
       if (type.getTypeName().equalsIgnoreCase("Neuron Input Value")) {
         for (Neuron neuron : network.getFlatNeuronList()) {
           returnList.add(getNeuronConsumer(this, neuron, type.getMethodName()));
         }
       } else {
         for (Neuron neuron : network.getFlatNeuronList()) {
           String description = type.getDescription(neuron.getId());
           PotentialConsumer consumer =
               getAttributeManager().createPotentialConsumer(neuron, type);
           consumer.setCustomDescription(description);
           returnList.add(consumer);
         }
       }
     } else if (type.getTypeName().equalsIgnoreCase("Synapse")) {
       for (Synapse synapse : network.getFlatSynapseList()) {
         String description = type.getDescription(synapse.getId());
         PotentialConsumer consumer = getAttributeManager().createPotentialConsumer(synapse, type);
         consumer.setCustomDescription(description);
         returnList.add(consumer);
       }
     } else if (type.getTypeName().equalsIgnoreCase("NeuronGroup")) {
       // Handle NeuronGroup attributes
       for (Group group : network.getFlatGroupList()) {
         if (group instanceof NeuronGroup) {
           PotentialConsumer consumer =
               getNeuronGroupConsumer(this, (NeuronGroup) group, type.getMethodName());
           returnList.add(consumer);
         }
       }
     } else if (type.getTypeName().equalsIgnoreCase("SynapseGroup")) {
       // Handle SynapseGroup attributes
       for (Group group : network.getFlatGroupList()) {
         if (group instanceof SynapseGroup) {
           PotentialConsumer consumer =
               getAttributeManager()
                   .createPotentialConsumer(group, "setWeightVector", double[].class);
           consumer.setCustomDescription("Synapse Group: " + group.getLabel());
           returnList.add(consumer);
         }
       }
     }
   }
   return returnList;
 }
示例#2
0
  /** Initialize attribute types and listeners. */
  private void init() {

    // Initialize attribute types and their default visibility
    addProducerType(
        new AttributeType(this, "Neuron Activation", "getActivation", double.class, true));
    addProducerType(
        new AttributeType(this, "Neuron Upper Bound", "getUpperBound", double.class, false));
    addProducerType(
        new AttributeType(this, "Neuron Lower Bound", "getLowerBound", double.class, false));
    addProducerType(new AttributeType(this, "Neuron Label", "getLabel", String.class, false));
    addProducerType(new AttributeType(this, "Synapse", "getStrength", double.class, false));
    addProducerType(
        new AttributeType(
            this, "NeuronGroupActivations", "getExternalActivations", double[].class, true));
    addProducerType(
        new AttributeType(this, "NeuronGroupSpikes", "getSpikeIndexes", double[].class, true));
    addProducerType(
        new AttributeType(this, "SynapseGroup", "getWeightVector", double[].class, true));

    addConsumerType(
        new AttributeType(this, "Neuron Input Value", "setInputValue", double.class, true));
    addConsumerType(
        new AttributeType(this, "Neuron Activation", "setActivation", double.class, false));
    addConsumerType(
        new AttributeType(this, "Neuron Upper Bound", "setUpperBound", double.class, false));
    addConsumerType(
        new AttributeType(this, "Neuron Lower Bound", "setLowerBound", double.class, false));
    addConsumerType(new AttributeType(this, "Neuron Label", "setLabel", String.class, false));
    addConsumerType(new AttributeType(this, "Synapse", "setStrength", double.class, false));
    addConsumerType(new AttributeType(this, "NeuronGroup", "setInputValues", double[].class, true));
    addConsumerType(
        new AttributeType(this, "SynapseGroup", "setWeightVector", double[].class, false));

    network.addNeuronListener(
        new NeuronListener() {
          /** {@inheritDoc} */
          public void neuronAdded(NetworkEvent<Neuron> e) {
            setChangedSinceLastSave(true);
            firePotentialAttributesChanged();
          }

          /** {@inheritDoc} */
          public void neuronTypeChanged(NetworkEvent<NeuronUpdateRule> e) {
            setChangedSinceLastSave(true);
          }

          /** {@inheritDoc} */
          public void neuronMoved(NetworkEvent<Neuron> e) {
            setChangedSinceLastSave(true);
          }

          /** {@inheritDoc} */
          public void neuronRemoved(NetworkEvent<Neuron> e) {
            setChangedSinceLastSave(true);
            firePotentialAttributesChanged();
            fireAttributeObjectRemoved(e.getObject());
          }

          @Override
          public void neuronChanged(NetworkEvent<Neuron> e) {
            setChangedSinceLastSave(true);
          }

          @Override
          public void labelChanged(NetworkEvent<Neuron> e) {
            setChangedSinceLastSave(true);
          }
        });

    network.addSynapseListener(
        new SynapseListener() {

          public void synapseAdded(NetworkEvent<Synapse> networkEvent) {
            setChangedSinceLastSave(true);
            firePotentialAttributesChanged();
          }

          public void synapseChanged(NetworkEvent<Synapse> networkEvent) {
            setChangedSinceLastSave(true);
            firePotentialAttributesChanged();
          }

          public void synapseRemoved(NetworkEvent<Synapse> networkEvent) {
            setChangedSinceLastSave(true);
            firePotentialAttributesChanged();
          }

          public void synapseTypeChanged(NetworkEvent<SynapseUpdateRule> networkEvent) {
            setChangedSinceLastSave(true);
          }
        });
  }
示例#3
0
 @Override
 public String getXML() {
   return Network.getXStream().toXML(network);
 }
示例#4
0
 @Override
 public void update() {
   network.update();
 }
示例#5
0
 @Override
 public void save(final OutputStream output, final String format) {
   network.preSaveInit();
   Network.getXStream().toXML(network, output);
   network.postSaveReInit();
 }
示例#6
0
 /** {@inheritDoc} */
 public static NetworkComponent open(
     final InputStream input, final String name, final String format) {
   Network newNetwork = (Network) Network.getXStream().fromXML(input);
   return new NetworkComponent(name, newNetwork);
 }