Initializes the Streaming HS-Trees classifier on the argument trainingPoints.

@param trainingPoints the Collection of instance with which to initialize the Streaming Hs-Trees classifier.
351964
@Override
	public void initialize(Collection<Instance> trainingPoints)
	{
		Iterator<Instance> trgPtsIterator = trainingPoints.iterator();
		
		if(trgPtsIterator.hasNext() && this.numInstances == 0)
		{
			Instance inst = trgPtsIterator.next();
			this.buildForest(inst);
			this.trainOnInstance(inst);
		}
		
		while(trgPtsIterator.hasNext())
		{
			this.trainOnInstance((Instance)trgPtsIterator.next());			
		}
	}
654938
public void setPoints(List<GeoPoint> points) {
        mOutline.clearPath();
        mOriginalPoints = new ArrayList<>(points.size());
        for (GeoPoint p:points) {
            mOriginalPoints.add(p);
        }
        mOutline.setPoints(points);
        setDefaultInfoWindowLocation();
    }
694917
public void setEndpoints(java.util.Collection<Endpoint> endpoints) {
        if (endpoints == null) {
            this.endpoints = null;
            return;
        }

        this.endpoints = new com.amazonaws.internal.SdkInternalList<Endpoint>(endpoints);
    }
147718
protected static void initEndpointInfo(List<EndpointInfo> endpoints) {
        for (int i = 0; i < endpoints.size(); i++) {
            initEndpointInfo(endpoints.get(i));
        }
    }
911185
public final void train(Collection<Tree> trees, double weight) {
    // scan data
    for (Tree tree : trees) {
      train(tree, weight);
    }
  }
1164491
public void initialize( List<Point> dataSet ) {
		bestFitPoints.clear();

		if( dataSet.size() > matchToInput.length ) {
			matchToInput = new int[ dataSet.size() ];
			bestMatchToInput = new int[ dataSet.size() ];
		}
	}
1258706
public void setEndpointDescriptions(java.util.Collection<EndpointDescription> endpointDescriptions) {
        if (endpointDescriptions == null) {
            this.endpointDescriptions = null;
            return;
        }

        this.endpointDescriptions = new java.util.ArrayList<EndpointDescription>(endpointDescriptions);
    }
419578
private static void initMarkers() {

    if (initialized)
      return;

    Class<?> cExtClass = findExtClass(EXT_CLASS);

    if (cExtClass.isAssignableFrom(String.class)) {
      createDefaultMarkers();
    } else {
      createMultiMarkers(cExtClass);
    }

    if (!initialized)
      LOG.warn("SecureLogging Markers could not be initialized!");
    else
      LOG.debug("SecureLogging Markers created: '{}', ...", markerSecurSuccConfid.getName());
    return;
  }
1159364
public void setDBClusterEndpoints(java.util.Collection<DBClusterEndpoint> dBClusterEndpoints) {
        if (dBClusterEndpoints == null) {
            this.dBClusterEndpoints = null;
            return;
        }

        this.dBClusterEndpoints = new com.amazonaws.internal.SdkInternalList<DBClusterEndpoint>(dBClusterEndpoints);
    }
1322452
public void setDatapoints(java.util.Collection<Datapoint> datapoints) {
        if (datapoints == null) {
            this.datapoints = null;
            return;
        }

        this.datapoints = new java.util.ArrayList<Datapoint>(datapoints);
    }
1064610
public void init(@NonNull VoidConfiguration voidConfiguration, @NonNull Transport transport,
                    TrainingDriver<? extends TrainingMessage> trainer) {
        /**
         * Basic plan here:
         *      start publishers/listeners/subscribers
         *      determine role of the current instance:
         *          Shard
         *          Backup
         *          Client
         *      shutdown unwanted aeron helpers (according to role)
         *      wait for incoming task queries (according to role
         *
         */
        if (initFinished.get())
            return;

        synchronized (this) {
            if (initLocker.compareAndSet(false, true)) {
                this.trainer = trainer;
                this.voidConfiguration = voidConfiguration;

                this.transport = transport;

                // first we need to check, if our current IP matches designated shards or backup
                if (nodeRole == NodeRole.NONE && (voidConfiguration.getForcedRole() == null
                                || voidConfiguration.getForcedRole() == NodeRole.NONE)) {
                    Pair<NodeRole, String> pair = null;
                    if (voidConfiguration.getShardAddresses().size() == 1
                                    && voidConfiguration.getShardAddresses().get(0).contains("127.0.0.1")) {
                        pair = Pair.create(NodeRole.SHARD, voidConfiguration.getShardAddresses().get(0));
                    } else {
                        pair = getRole(voidConfiguration, getLocalAddresses());
                    }
                    nodeRole = pair.getFirst();

                    String ipAndPort = pair.getSecond();
                    String ip = "127.0.0.1";
                    int port = 0;
                    // if we're Shard and have port enforced
                    if (ipAndPort.contains(":")) {
                        String[] split = ipAndPort.split(":");
                        ip = split[0];
                        port = Integer.valueOf(split[1]);
                    } else {
                        ip = ipAndPort;
                        port = voidConfiguration.getUnicastControllerPort();
                    }

                    // if we're Shard here, we should define shardIndex
                    if (nodeRole == NodeRole.SHARD && voidConfiguration.getShardAddresses().size() > 1) {
                        short cnt = 0;
                        for (String shard : voidConfiguration.getShardAddresses()) {
                            String lIp = null;
                            if (shard.contains(":")) {
                                String[] split = ipAndPort.split(":");
                                lIp = split[0];
                            } else
                                lIp = shard;

                            if (lIp.equals(ip)) {
                                shardIndex = cnt;
                            }
                            cnt++;
                        }
                    }

                    this.transport.init(voidConfiguration, clipboard, nodeRole, ip, port, shardIndex);

                } else {
                    if (nodeRole == NodeRole.NONE)
                        nodeRole = voidConfiguration.getForcedRole();

                    // if we're using forced roles here, we'll assume that controllerAddress belongs to this box
                    String localIp = voidConfiguration.getExecutionMode() == ExecutionMode.MANAGED
                                    ? voidConfiguration.getControllerAddress() : "127.0.0.1";

                    this.transport.init(voidConfiguration, clipboard, nodeRole, localIp,
                                    voidConfiguration.getUnicastControllerPort(), shardIndex);
                }


                // TODO: we need real ip only if this is a shard *FOR NOW*, but later we'll need it for client as well

                // we launch message processing if we're not in debug mode
                if (!manualMode.get()) {
                    processingThreads = new Thread[numThreads];
                    processingRunnables = new Runnable[numThreads];

                    for (int x = 0; x < numThreads; x++) {
                        processingThreads[x] = new Thread(() -> {
                            runner.set(true);
                            while (runner.get()) {
                                try {
                                    //VoidMessage message = transport.takeMessage();

                                    //                                    if (nodeRole == NodeRole.SHARD)
                                    //                                        log.info("Processing message: {}", message.getClass().getSimpleName());

                                    handleMessage(transport.takeMessage());

                                } catch (ND4JIllegalStateException e) {
                                    throw new RuntimeException(e);
                                } catch (Exception e) {
                                    throw new RuntimeException(e);
                                }
                            }
                        });

                        //executor.submit(processingRunnables[x);

                        // TODO: maybe find the way to guarantee affinity in some other way, to make different devices usable as well?
                        Nd4j.getAffinityManager().attachThreadToDevice(processingThreads[x],
                                        Nd4j.getAffinityManager().getDeviceForCurrentThread());
                        processingThreads[x].setDaemon(true);
                        processingThreads[x].setName("VoidParameterServer messages handling thread");
                        processingThreads[x].start();
                    }
                }


                log.info("Launching transport...");
                transport.launch(Transport.ThreadingModel.DEDICATED_THREADS);
                trainer.init(this.voidConfiguration, this.transport, storage, clipboard);

                initFinished.set(true);
            }
        }
    }
116318
protected static List<double[]> mergeInitPoints(List<double[]> basePoints,
            List<double[]> targetPoints)
    {
        List<double[]> mergedFeatures = new ArrayList<>();
        mergedFeatures.addAll(basePoints);
        mergedFeatures.addAll(targetPoints);

        return mergedFeatures;
    }
1152877
@Override
    public void trainOnInstanceImpl(Instance inst) {
        if (this.reset == true) {
            this.m_numClasses = inst.numClasses();
            double laplace = this.laplaceCorrectionOption.getValue();
            int numAttributes = inst.numAttributes();

            m_probOfClass = new double[m_numClasses];
            Arrays.fill(m_probOfClass, laplace);

            m_classTotals = new double[m_numClasses];
            Arrays.fill(m_classTotals, laplace * numAttributes);

            m_wordTotalForClass = new DoubleVector[m_numClasses];
            for (int i = 0; i< m_numClasses; i++) {
                //Arrays.fill(wordTotal, laplace);
                m_wordTotalForClass[i] = new DoubleVector();
            }
            this.reset = false;
        }
        // Update classifier
        int classIndex = inst.classIndex();
        int classValue = (int) inst.classValue();//value(classIndex);

        double w = inst.weight();
        m_probOfClass[classValue] += w;

        m_classTotals[classValue] += w * totalSize(inst);
        double total = m_classTotals[classValue];

        for (int i = 0; i < inst.numValues(); i++) {
            int index = inst.index(i);
            if (index != classIndex && !inst.isMissing(i)) {
                //m_wordTotalForClass[index][classValue] += w * inst.valueSparse(i);
                double laplaceCorrection = 0.0;
                if (m_wordTotalForClass[classValue].getValue(index)== 0) {
                    laplaceCorrection = this.laplaceCorrectionOption.getValue();
                }
                m_wordTotalForClass[classValue].addToValue(index, w * inst.valueSparse(i) + laplaceCorrection);
            }
        }
    }
961838
public void setStartingInstances(java.util.Collection<InstanceStateChange> startingInstances) {
        if (startingInstances == null) {
            this.startingInstances = null;
            return;
        }

        this.startingInstances = new com.amazonaws.internal.SdkInternalList<InstanceStateChange>(startingInstances);
    }
179342
@Override
  public final void initialize(FlowletContext ctx) throws Exception {
    super.initialize(ctx);
    portsAnnouncementList = Lists.newArrayList();
    DefaultInputFlowletConfigurer configurer = new DefaultInputFlowletConfigurer(this);
    create(configurer);
    InputFlowletSpecification spec = configurer.createInputFlowletSpec();

    dataIngestionPortsMap = Maps.newHashMap();
    int httpPort = 0;
    if (ctx.getRuntimeArguments().get(Constants.HTTP_PORT) != null) {
      httpPort = Integer.parseInt(ctx.getRuntimeArguments().get(Constants.HTTP_PORT));
    }
    dataIngestionPortsMap.put(Constants.HTTP_PORT, httpPort);
    for (String inputName : spec.getInputSchemas().keySet()) {
      int tcpPort = 0;
      if (ctx.getRuntimeArguments().get(Constants.TCP_INGESTION_PORT_PREFIX + inputName) != null) {
        tcpPort = Integer.parseInt(ctx.getRuntimeArguments().get(Constants.TCP_INGESTION_PORT_PREFIX + inputName));
      }
      dataIngestionPortsMap.put(Constants.TCP_INGESTION_PORT_PREFIX + inputName, tcpPort);
    }

    // Setup temporary directory structure
    tmpFolder = Files.createTempDir();
    File baseDir = new File(tmpFolder, "baseDir");
    baseDir.mkdirs();

    InputFlowletConfiguration inputFlowletConfiguration = new LocalInputFlowletConfiguration(baseDir, spec);
    File binDir = inputFlowletConfiguration.createStreamEngineProcesses();

    healthInspector = new HealthInspector(this);
    metricsRecorder = new MetricsRecorder(metrics);

    //Initiating AbstractInputFlowlet Components
    recordQueue = new GDATRecordQueue();

    //Initiating Netty TCP I/O ports
    inputFlowletService = new InputFlowletService(binDir, spec, healthInspector, metricsRecorder, recordQueue,
                                                  dataIngestionPortsMap, this);
    inputFlowletService.startAndWait();

    //Starting health monitor service
    healthInspector.startAndWait();

    //Initializing methodsDriver
    Map<String, StreamSchema> schemaMap = MetaInformationParser.getSchemaMap(new File(binDir.toURI()));
    methodsDriver = new MethodsDriver(this, schemaMap);

    //Initialize stopwatch and retry counter
    stopwatch = new Stopwatch();
    retryCounter = 0;
  }
613640
@Override
    public void trainOnInstanceImpl(Instance instance) {

        if (m_weights == null) {
            int length;
             if (instance.classAttribute().isNominal()) {
                 length = instance.numClasses();
             } else {
                 length = 1;
             }
            m_weights = new DoubleVector[length];
            m_bias = new double[length];
            for (int i = 0; i < m_weights.length; i++){
                m_weights[i] = new DoubleVector(); 
                m_bias[i] = 0.0;
            }
        }
        for (int i = 0; i < m_weights.length; i++){
                this.trainOnInstanceImpl(instance, i); 
            }
        m_t++;
    }
1020947
@Override
	public void trainOnInstanceImpl(Instance inst) {
		double[] x = inst.toDoubleArray();
		if (this.numDimensions != x.length) {
			System.out.println("Line skipped because line dimension is "
					+ x.length + " instead of " + this.numDimensions);
			return;
		}
		// Starts with the buffer phase to calculate the starting threshold
		if (this.bufferPhase) {
			// Calculates the pairwise distance to all unequal point in the
			// buffer
			for (double[] point : this.buffer) {
				double d = Metric.distanceSquared(point, x);
				if (d > 0) {
					this.pairwiseDifferent++;
					if (d < minDistance) {
						minDistance = d;
					}
				}
			}
			this.buffer.add(x);

			// Checks if the buffer is large enough
			if (this.pairwiseDifferent >= this.maxNumClusterFeatures + 1) {
				// Calculates the starting threshold
				this.T = 16 * minDistance;
				this.root.setThreshold(calcRSquared(1));
				this.bufferPhase = false;
				// Adds all points to the ClusteringFeature tree
				for (double[] point : this.buffer) {
					bicoUpdate(point);
				}
				this.buffer.clear();
				this.buffer = null;
			}
		} else {
			// Adds the point directly to the ClusteringFeature tree
			bicoUpdate(x);
		}
	}