Example usage for javafx.collections ObservableSet size

List of usage examples for javafx.collections ObservableSet size

Introduction

In this page you can find the example usage for javafx.collections ObservableSet size.

Prototype

int size();

Source Link

Document

Returns the number of elements in this set (its cardinality).

Usage

From source file:model.scenario.OneLinkSupplyChainResult.java

public static void extractAndPrintSlopesOfBeefSellers(MacroII model) {
    Preconditions.checkState(OneLinkSupplyChainScenario.class.isAssignableFrom(model.getScenario().getClass()));
    //wood//from  w ww. ja  va  2 s .  c o m
    final ObservableSet<EconomicAgent> lumberMills = model.getMarket(OneLinkSupplyChainScenario.INPUT_GOOD)
            .getSellers();
    double salesSlopes[] = new double[lumberMills.size()];
    double hrSlopes[] = new double[lumberMills.size()];
    int i = 0;
    for (EconomicAgent e : lumberMills) {
        Firm f = (Firm) e;
        final double hrSlope = f.getHRs().iterator().next()
                .getLatestObservation(PurchasesDataType.PREDICTED_SUPPLY_SLOPE);
        hrSlopes[i] = hrSlope;
        final double saleSlope = f.getSalesDepartment(OneLinkSupplyChainScenario.INPUT_GOOD)
                .getLatestObservation(SalesDataType.PREDICTED_DEMAND_SLOPE);
        salesSlopes[i] = saleSlope;
        i++;
    }
    System.out.println("wood slopes");
    System.out.println("sales: " + Arrays.toString(salesSlopes));
    System.out.println("hr: " + Arrays.toString(hrSlopes));

    //furniture
    final ObservableSet<EconomicAgent> furniturePlants = model.getMarket(OneLinkSupplyChainScenario.INPUT_GOOD)
            .getBuyers();
    salesSlopes = new double[furniturePlants.size()];
    hrSlopes = new double[furniturePlants.size()];
    double pdSlopes[] = new double[furniturePlants.size()];

    i = 0;
    for (EconomicAgent e : furniturePlants) {
        Firm f = (Firm) e;
        final double hrSlope = f.getHRs().iterator().next()
                .getLatestObservation(PurchasesDataType.PREDICTED_SUPPLY_SLOPE);
        hrSlopes[i] = hrSlope;
        final double saleSlope = f.getSalesDepartment(OneLinkSupplyChainScenario.OUTPUT_GOOD)
                .getLatestObservation(SalesDataType.PREDICTED_DEMAND_SLOPE);
        salesSlopes[i] = saleSlope;
        final double pdSlope = f.getPurchaseDepartment(OneLinkSupplyChainScenario.INPUT_GOOD)
                .getLatestObservation(PurchasesDataType.PREDICTED_SUPPLY_SLOPE);
        pdSlopes[i] = pdSlope;
        i++;
    }
    System.out.println("furniture slopes");
    System.out.println("sales: " + Arrays.toString(salesSlopes));
    System.out.println("hr: " + Arrays.toString(hrSlopes));
    System.out.println("pd: " + Arrays.toString(pdSlopes));
}