Construct average throughput.

@param scenarioResults   the scenario results
@param scenarioGraphData the scenario graph data
776825
static void constructAverageThroughput(Map.Entry<String, LrProjectScenarioResults> scenarioResults,
                                           JSONObject scenarioGraphData) {
        Map<Integer, WholeRunResult> averageThroughputResults = scenarioResults.getValue().getAverageThroughputResults();
        JSONObject averageThroughputResultsGraphSet =
                extractWholeRunSlaResult(averageThroughputResults, "Bytes/Sec");
        if (!averageThroughputResultsGraphSet.getJSONArray(LABELS).isEmpty()) {
            averageThroughputResultsGraphSet.put(TITLE, "Average Throughput per second");
            averageThroughputResultsGraphSet.put(X_AXIS_TITLE, "Build number");
            averageThroughputResultsGraphSet.put(Y_AXIS_TITLE, "Bytes");
            averageThroughputResultsGraphSet.put(DESCRIPTION,
                    " Displays the amount of throughput (in bytes) on the Web server during the load test. " +
                            "Throughput represents the amount of data that the Vusers received from the server at" +
                            " any given second. This graph helps you to evaluate the amount of load Vusers " +
                            "generate, in terms of server throughput.\n");
            scenarioGraphData.put("averageThroughput", averageThroughputResultsGraphSet);
        }
    }
1266962
public UserScenarioValidation createUserScenarioValidation(final int scenarioId) {
        return invoke(USER_SCENARIO_VALIDATIONS,
                new RequestClosure<JsonObject>() {
                    @Override
                    public JsonObject call(Invocation.Builder request) {
                        JsonObject     json = Json.createObjectBuilder().add("user_scenario_id", scenarioId).build();
                        Entity<String> data = Entity.entity(json.toString(), MediaType.APPLICATION_JSON_TYPE);
                        return request.post(data, JsonObject.class);
                    }
                },
                new ResponseClosure<JsonObject, UserScenarioValidation>() {
                    @Override
                    public UserScenarioValidation call(JsonObject json) {
                        return new UserScenarioValidation(json);
                    }
                }
        );
    }
156167
@Override
    public void putGraph(Model data) {

        if (data == null)
            return;

        // Use HTTP protocol if possible
        if (this.sparqlServiceEndpoint != null) {
            datasetAccessor.putModel(data);
        } else {
            this.putGraphSparqlQuery(data);
        }

    }
973516
private WorkflowStatusDataResult executeWFSectionNodeDispatch(
            StepExecutionContext executionContext,
            int stepCount,
            List<StepExecutionResult> results,
            Map<String, Collection<StepExecutionResult>> failures,
            final Map<Integer, StepExecutionResult> stepFailures,
            IWorkflow flowsection,
            WFSharedContext sharedContext
    )
            throws ExecutionServiceException, DispatcherException
    {
        logger.debug("Node dispatch for " + flowsection.getCommands().size() + " steps");
        final DispatcherResult dispatch;
        final WorkflowExecutionItem innerLoopItem = createInnerLoopItem(flowsection);

        final Dispatchable dispatchedWorkflow = new DispatchedWorkflow(
                getFramework().getWorkflowExecutionService(),
                innerLoopItem,
                stepCount,
                executionContext.getStepContext()
        );

        WFSharedContext dispatchSharedContext = new WFSharedContext(sharedContext);
        //dispatch the sequence of dispatched items to each node
        dispatch = getFramework().getExecutionService().dispatchToNodes(
                ExecutionContextImpl.builder(executionContext)
                                    .sharedDataContext(dispatchSharedContext)
                                    .stepNumber(stepCount)
                                    .build(),
                dispatchedWorkflow
        );

        logger.debug("Node dispatch result: " + dispatch);
        WFSharedContext resultData = extractWFDispatcherResult(
                dispatch,
                results,
                failures,
                stepFailures,
                flowsection.getCommands().size(),
                stepCount
        );
        return workflowResult(dispatch.isSuccess(), null, ControlBehavior.Continue, resultData);
    }
402618
@Override
  public void outputText(SDocumentGraph graph, boolean alignmc, int matchNumber,
    Writer out) throws IOException, IllegalArgumentException
  {

    // first match
    if (matchNumber == 0)
    {
      // output header
      List<String> headerLine = new ArrayList<>();
      for(Map.Entry<Integer, TreeSet<String>> match: annotationsForMatchedNodes.entrySet())
      {
        int node_id = match.getKey();
        headerLine.add(String.valueOf(node_id) + "_id");
        headerLine.add(String.valueOf(node_id) + "_span");
        for (String annoName: match.getValue())
        {
          headerLine.add(String.valueOf(node_id) + "_anno_" + annoName);
        }
      }
      for (String key: metakeys) {
        headerLine.add("meta_" + key);
      }
      out.append(StringUtils.join(headerLine, "\t"));
      out.append("\n");
    }

    // output nodes in the order of the matches
    SortedMap<Integer, String> contentLine = new TreeMap<>();
    for (SNode node: this.getMatchedNodes(graph)) {
      List<String> nodeLine = new ArrayList<>();
      // export id
      RelannisNodeFeature feats = RelannisNodeFeature.extract(node);
      nodeLine.add(String.valueOf(feats.getInternalID()));
      // export spanned text
      String span = graph.getText(node);
      if (span != null)
        nodeLine.add(graph.getText(node));
      else
        nodeLine.add("");
      // export annotations
      int node_id = node
        .getFeature(AnnisConstants.ANNIS_NS, AnnisConstants.FEAT_MATCHEDNODE)
        .getValue_SNUMERIC().intValue();
      for (String annoName: annotationsForMatchedNodes.get(node_id))
      {
        SAnnotation anno = node.getAnnotation(annoName);
        if (anno != null)
        {
          nodeLine.add(anno.getValue_STEXT());
        }
        else
          nodeLine.add("'NULL'");
      }
      // add everything to line
      contentLine.put(node_id, StringUtils.join(nodeLine, "\t"));
    }

    out.append(StringUtils.join(contentLine.values(), "\t"));

    // export Metadata
    // TODO cache the metadata
    if(!metakeys.isEmpty()) {
      // TODO is this the best way to get the corpus name?
      String corpus_name = CommonHelper.getCorpusPath(java.net.URI.create(graph.getDocument().getId())).get(0);
      List<Annotation> asList = Helper.getMetaData(corpus_name, graph.getDocument().getName());
      for(Annotation anno : asList)
      {
        if (metakeys.contains(anno.getName()))
          out.append("\t" + anno.getValue());
      }
    }

    out.append("\n");
  }
723844
public static void main(String... args) throws Exception {

		// Checking input parameters
		final ParameterTool params = ParameterTool.fromArgs(args);

		// set up execution environment
		ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

		final int maxIterations = params.getInt("iterations", 10);

		// make parameters available in the web interface
		env.getConfig().setGlobalJobParameters(params);

		// read vertex and edge data
		DataSet<Long> vertices = getVertexDataSet(env, params);
		DataSet<Tuple2<Long, Long>> edges = getEdgeDataSet(env, params).flatMap(new UndirectEdge());

		// assign the initial components (equal to the vertex id)
		DataSet<Tuple2<Long, Long>> verticesWithInitialId =
			vertices.map(new DuplicateValue<Long>());

		// open a delta iteration
		DeltaIteration<Tuple2<Long, Long>, Tuple2<Long, Long>> iteration =
				verticesWithInitialId.iterateDelta(verticesWithInitialId, maxIterations, 0);

		// apply the step logic: join with the edges, select the minimum neighbor, update if the component of the candidate is smaller
		DataSet<Tuple2<Long, Long>> changes = iteration.getWorkset().join(edges).where(0).equalTo(0).with(new NeighborWithComponentIDJoin())
				.groupBy(0).aggregate(Aggregations.MIN, 1)
				.join(iteration.getSolutionSet()).where(0).equalTo(0)
				.with(new ComponentIdFilter());

		// close the delta iteration (delta and new workset are identical)
		DataSet<Tuple2<Long, Long>> result = iteration.closeWith(changes, changes);

		// emit result
		if (params.has("output")) {
			result.writeAsCsv(params.get("output"), "\n", " ");
			// execute program
			env.execute("Connected Components Example");
		} else {
			System.out.println("Printing result to stdout. Use --output to specify output path.");
			result.print();
		}
	}
319372
public void addScenario(Class<? extends Scenario> scenarioClass,
            String scenarioID, String initialState, Properties properties,
            String gatewayDeviceID, String externalLinkID)
            throws ShanksException {
        // throws NonGatewayDeviceException, TooManyConnectionException,
        // DuplicatedIDException, AlreadyConnectedScenarioException,
        // SecurityException, NoSuchMethodException, IllegalArgumentException,
        // InstantiationException, IllegalAccessException,
        // InvocationTargetException {
        Constructor<? extends Scenario> c;
        Scenario scenario;
        try {
            c = scenarioClass.getConstructor(new Class[] { String.class,
                    String.class, Properties.class, Logger.class });
            scenario = c.newInstance(scenarioID, initialState, properties, this.getLogger());
        } catch (SecurityException e) {
            throw new ShanksException(e);
        } catch (NoSuchMethodException e) {
            throw new ShanksException(e);
        } catch (IllegalArgumentException e) {
            throw new ShanksException(e);
        } catch (InstantiationException e) {
            throw new ShanksException(e);
        } catch (IllegalAccessException e) {
            throw new ShanksException(e);
        } catch (InvocationTargetException e) {
            throw new ShanksException(e);
        }

        Device gateway = (Device) scenario.getNetworkElement(gatewayDeviceID);
        Link externalLink = (Link) this.getNetworkElement(externalLinkID);
        if (!scenario.getCurrentElements().containsKey(gatewayDeviceID)) {
            throw new NonGatewayDeviceException(scenario, gateway, externalLink);
        } else {
            gateway.connectToLink(externalLink);
            if (!this.getCurrentElements().containsKey(externalLink.getID())) {
                this.addNetworkElement(externalLink);
            }
            if (!this.scenarios.containsKey(scenario)) {
                this.scenarios.put(scenario, new ArrayList<Link>());
            } else {
                List<Link> externalLinks = this.scenarios.get(scenario);
                if (!externalLinks.contains(externalLink)) {
                    externalLinks.add(externalLink);
                } else if (externalLink.getLinkedDevices().contains(gateway)) {
                    throw new AlreadyConnectedScenarioException(scenario,
                            gateway, externalLink);
                }
            }
        }
    }
256010
@Override
    public void perform(GraphRewrite event, EvaluationContext context)
    {
        checkVariableName(event, context);
        WindupVertexFrame payload = resolveVariable(event, getVariableName());
        if (payload instanceof FileReferenceModel)
        {
            FileModel file = ((FileReferenceModel) payload).getFile();
            perform(event, context, (XmlFileModel) file);
        }
        else
        {
            super.perform(event, context);
        }

    }
1357543
private static void initDataId(String scenarioName) throws TechnicalException {
        final List<DataIndex> indexData = new ArrayList<>();
        try {
            Context.getDataInputProvider().prepare(scenarioName);
            final Class<Model> model = Context.getDataInputProvider().getModel(Context.getModelPackages());
            if (model != null) {
                final String[] headers = Context.getDataInputProvider().readLine(0, false);
                if (headers != null) {
                    final Constructor<Model> modelConstructor = DataUtils.getModelConstructor(model, headers);
                    final Map<String, ModelList> fusionedData = DataUtils.fusionProcessor(model, modelConstructor);
                    int dataIndex = 0;
                    for (final Entry<String, ModelList> e : fusionedData.entrySet()) {
                        dataIndex++;
                        indexData.add(new DataIndex(dataIndex, e.getValue().getIds()));
                    }
                } else {
                    logger.error(Messages.getMessage(ScenarioInitiator.SCENARIO_INITIATOR_ERROR_EMPTY_FILE));
                }
            } else {
                for (int i = 1; i < Context.getDataInputProvider().getNbLines(); i++) {
                    final List<Integer> index = new ArrayList<>();
                    index.add(i);
                    indexData.add(new DataIndex(i, index));
                }
            }
            Context.getDataInputProvider().setIndexData(indexData);
        } catch (final Exception te) {
            throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE) + te.getMessage(), te);
        }
    }
683469
public <T extends RegressionEvaluation> T evaluateRegression(JavaRDD<DataSet> data) {
        return evaluateRegression(data, DEFAULT_EVAL_SCORE_BATCH_SIZE);
    }
779053
@Override
    public void addModelToGraph(URI graphUri, Model data) {
        if (graphUri == null || data == null)
            return;

        // Use HTTP protocol if possible
        if (this.sparqlServiceEndpoint != null) {
            datasetAccessor.add(graphUri.toASCIIString(), data);
        } else {
            this.addModelToGraphSparqlQuery(graphUri, data);
        }
    }
58898
protected void processResult(RHI aggregatedResult) {
        // Process the result with all result handlers
        for (ResultHandler<RHI> resultHandler : resultHandlers) {
            resultHandler.handleResult(aggregatedResult);
        }
    }
265171
public String buildResultsInfoMessage(FeatureIndexResults results, double tolerance, Projection projection) {
        return buildResultsInfoMessage(results, tolerance, null, projection);
    }
133939
public ScenarioPortrayal createScenarioPortrayal() throws ShanksException {
        logger.fine("Creating Scenario Portrayal...");
        String dimensions = (String) this.getProperty(Scenario.SIMULATION_GUI);
        if (dimensions.equals(Scenario.SIMULATION_2D)) {
            logger.fine("Creating Scenario2DPortrayal");
            return this.createScenario2DPortrayal();
        } else if (dimensions.equals(Scenario.SIMULATION_3D)) {
            logger.fine("Creating Scenario3DPortrayal");
            return this.createScenario3DPortrayal();
        } else if (dimensions.equals(Scenario.NO_GUI)) {
            return null;
        }
        return null;

    }
1126983
@Override
	public DataSet<Result<K>> runInternal(Graph<K, VV, EV> input)
			throws Exception {
		// u, v, w, bitmask
		DataSet<TriangleListing.Result<K>> triangles = input
			.run(new TriangleListing<K, VV, EV>()
				.setParallelism(parallelism));

		// u, edge count
		DataSet<Tuple2<K, LongValue>> triangleVertices = triangles
			.flatMap(new SplitTriangles<>())
				.name("Split triangle vertices");

		// u, triangle count
		DataSet<Tuple2<K, LongValue>> vertexTriangleCount = triangleVertices
			.groupBy(0)
			.reduce(new CountTriangles<>())
			.setCombineHint(CombineHint.HASH)
				.name("Count triangles")
				.setParallelism(parallelism);

		// u, deg(u)
		DataSet<Vertex<K, Degrees>> vertexDegree = input
			.run(new VertexDegrees<K, VV, EV>()
				.setIncludeZeroDegreeVertices(includeZeroDegreeVertices.get())
				.setParallelism(parallelism));

		// u, deg(u), triangle count
		return vertexDegree
			.leftOuterJoin(vertexTriangleCount)
			.where(0)
			.equalTo(0)
			.with(new JoinVertexDegreeWithTriangleCount<>())
				.setParallelism(parallelism)
				.name("Clustering coefficient");
	}
207601
public static void marginals(final Hypergraph graph, final Hyperpotential w, final Algebra s,
            final Scores scores) {
        final int n = graph.getNodes().size();
        final double[] alpha = scores.alpha;
        final double[] beta = scores.beta;
        final double[] marginal = new double[n];
        int root = graph.getRoot().getId();
        
        // p(i) = \alpha_i * \beta_i / \beta_{root}
        for (Hypernode iNode : graph.getNodes()) {
            int i = iNode.getId();
            marginal[i] = s.divide(s.times(alpha[i], beta[i]), beta[root]); 
        }
        
        scores.marginal = marginal;
    }
535915
void writeResult(PrintStream out, DBIDs ids, OutlierResult result, ScalingFunction scaling, String label) {
    if(scaling instanceof OutlierScaling) {
      ((OutlierScaling) scaling).prepare(result);
    }
    out.append(label);
    DoubleRelation scores = result.getScores();
    for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
      double value = scores.doubleValue(iter);
      value = scaling != null ? scaling.getScaled(value) : value;
      out.append(' ').append(Double.toString(value));
    }
    out.append(FormatUtil.NEWLINE);
  }