All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.fchauvel.trio.Trio Maven / Gradle / Ivy

The newest version!
/**
 * This file is part of TRIO.
 *
 * TRIO is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TRIO is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with TRIO.  If not, see .
 */
/**
 * This file is part of TRIO :: Core.
 *
 * TRIO :: Core is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TRIO :: Core is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with TRIO :: Core.  If not, see .
 */
/**
 * This file is part of TRIO.
 *
 * TRIO is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TRIO is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with TRIO.  If not, see .
 */
/**
 * ====
 *     This file is part of TRIO :: Core.
 *
 *     TRIO :: Core is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Lesser General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     TRIO :: Core is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Lesser General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with TRIO :: Core.  If not, see .
 * ====
 *
 * ====
 *     This file is part of TRIO.
 *
 *     TRIO is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Lesser General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     TRIO is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Lesser General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with TRIO.  If not, see .
 * ====
 *
 *
 * This file is part of TRIO.
 *
 * TRIO is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TRIO is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with TRIO.  If not, see .
 */
/**
 * This file is part of TRIO :: Core.
 *
 * TRIO :: Core is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TRIO :: Core is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with TRIO :: Core.  If not, see .
 */
/**
 * This file is part of TRIO.
 *
 * TRIO is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TRIO is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with TRIO.  If not, see .
 */
/**
 *
 * This file is part of TRIO.
 *
 * TRIO is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TRIO is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with TRIO.  If not, see .
 */

package net.fchauvel.trio;

import net.fchauvel.trio.analytics.events.StatisticListener;
import net.fchauvel.trio.analytics.robustness.FailureSequenceAggregator;
import net.fchauvel.trio.analytics.robustness.RobustnessAggregator;
import net.fchauvel.trio.analytics.sensitivity.SensitivityRanking;
import net.fchauvel.trio.analytics.threats.ThreatRanking;
import net.fchauvel.trio.simulation.Simulation;
import net.fchauvel.trio.core.storage.Storage;
import net.fchauvel.trio.core.storage.StorageError;
import net.fchauvel.trio.simulation.Experiment;

/**
 * The Trio application
 */
public class Trio {

    private Storage storage;
    private final SimulationDispatcher simulation;
    private final net.fchauvel.trio.StatisticDispatcher statistics;

    public Trio(Storage storage) {
        this(storage, new SimulationDispatcher(), new StatisticDispatcher());
    }

    public Trio(Storage storage, SimulationDispatcher simulation, StatisticDispatcher analytics) {
        this.storage = storage;
        this.simulation = simulation;
        this.statistics = analytics;
        wireFailureSequenceAggregator();
        wireRobustnessAggregator();
        wireSensitiviyRanking();
        wireThreatRanking();
    }

    private void wireSensitiviyRanking() {
        SensitivityRanking sensitivity = new SensitivityRanking(statistics);
        simulation.register(sensitivity.getSimulationHandler());
    }

    private void wireThreatRanking() {
        ThreatRanking threats = new ThreatRanking(statistics);
        simulation.register(threats.getSimulationHandler());
        statistics.register(threats.getStatisticHandler());
    }

    private void wireRobustnessAggregator() {
        RobustnessAggregator robustness = new RobustnessAggregator(statistics);
        simulation.register(robustness.getSimulationHandler());
        statistics.register(robustness.getStatisticsHandler());
    }

    private void wireFailureSequenceAggregator() {
        FailureSequenceAggregator failureSequences = new FailureSequenceAggregator(statistics);
        this.simulation.register(failureSequences.getSimulationListener());
    }

    public void run(Simulation simulation, int runCount, final StatisticListener listener) throws StorageError {
        final int id = nextId();
        statistics.register(listener);
        Experiment experiment = new Experiment(id, simulation, storage.first(), runCount, this.simulation);
        experiment.execute();
    }

    private static int nextId() {
        runCounter += 1;
        return runCounter;
    }
    
    private static int runCounter = 0;


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy