Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.IOException;
- import java.math.BigDecimal;
- import java.util.LinkedList;
- import java.util.Properties;
- import java.util.Scanner;
- import java.util.logging.FileHandler;
- import java.util.logging.Logger;
- import java.util.logging.SimpleFormatter;
- import dissimlab.monitors.Diagram;
- import dissimlab.monitors.Diagram.DiagramType;
- import dissimlab.monitors.MonitoredVar;
- import dissimlab.monitors.Statistics;
- import dissimlab.simcore.SimControlException;
- import dissimlab.simcore.SimManager;
- public class Application {
- public static Properties properties;
- public static int NumberOfCashiers;
- public static int MaxClients;
- public static int AppearMin = Integer.parseInt(properties.getProperty("AppearMin"));
- public static int AppearMax = Integer.parseInt(properties.getProperty("AppearMax"));
- public static int StartServiceMin = Integer.parseInt(properties.getProperty("StartServiceMin"));
- public static int StartServiceMax = Integer.parseInt(properties.getProperty("StartServiceMax"));
- public static int EndServiceMin = Integer.parseInt(properties.getProperty("EndServiceMin"));
- public static int EndServiceMax = Integer.parseInt(properties.getProperty("EndServiceMax"));
- public static int ImpatintMin = Integer.parseInt(properties.getProperty("ImpatintMin"));
- public static int ImpatientMax = Integer.parseInt(properties.getProperty("ImpatientMax"));
- public static int RepairMin = Integer.parseInt(properties.getProperty("RepairMin"));
- public static int RepairMax = Integer.parseInt(properties.getProperty("RepairMax"));
- public static MonitoredVar mvServicingTime = new MonitoredVar();
- public static MonitoredVar mvNumberOfClients = new MonitoredVar();
- public static MonitoredVar mvResignation = new MonitoredVar();
- public static MonitoredVar mvWaitingTime = new MonitoredVar();
- public static final Logger LOGGER = Logger.getLogger(Application.class.getName());
- public static void main(String[] args) throws SimControlException, IOException {
- Properties properties = new Properties();
- properties.load(Application.class.getClassLoader().getResourceAsStream("settings.properties"));
- File file = new File("C:/Users/MatexN/Desktop/PSY_PROJEKT/log/simlog.log");
- file.createNewFile();
- FileHandler fh = new FileHandler(file.getPath());
- LOGGER.addHandler(fh);
- SimpleFormatter formatter = new SimpleFormatter();
- fh.setFormatter(formatter);
- LOGGER.setUseParentHandlers(false);
- LOGGER.info("Poczatek symulacji");
- System.out.println("Number of Cashiers: ");
- Scanner sc = new Scanner(System.in);
- Application.NumberOfCashiers = sc.nextInt();
- System.out.println("Max number of clients: ");
- Application.MaxClients = sc.nextInt();
- LOGGER.info("Number of Cashiers: " + String.valueOf(NumberOfCashiers));
- LOGGER.info("Max number of clients: " + String.valueOf(MaxClients));
- Bank scene = Bank.getInstance(Application.generateCashiers(Application.NumberOfCashiers));
- new CustomerAppearEvent(scene, scene.getGen().uniform(Application.AppearMin, Application.AppearMax));
- SimManager mgr = SimManager.getInstance();
- mgr.startSimulation();
- double wynik = new BigDecimal(Statistics.arithmeticMean(Application.mvServicingTime)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
- LOGGER.info("Oczekiwany graniczny czas obsługi klienta: " + wynik);
- wynik = new BigDecimal(Statistics.arithmeticMean(Application.mvNumberOfClients)).setScale(2, BigDecimal.ROUND_HALF_UP).intValue();
- LOGGER.info("Oczekiwana graniczna liczba klientow w kolejce: " + wynik);
- wynik = new BigDecimal(Statistics.arithmeticMean(Application.mvResignation)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
- LOGGER.info("Prawdopodobienstwo rezygnacji z obslugi " + wynik);
- wynik = new BigDecimal(Statistics.arithmeticMean(Application.mvWaitingTime)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
- LOGGER.info("Oczekiwany graniczny czas oczekiwania w kolejce " + wynik);
- Diagram d3 = new Diagram(DiagramType.HISTOGRAM, "Oczekiwany graniczny czas obsługi klienta:");
- d3.add(Application.mvServicingTime, java.awt.Color.BLUE);
- d3.show();
- Diagram d = new Diagram(DiagramType.DISTRIBUTION, "Prawdopodobienstwo rezygnacji z obslugi");
- d.add(Application.mvResignation, java.awt.Color.RED);
- d.show();
- Diagram d1 = new Diagram(DiagramType.HISTOGRAM, "Oczekiwany graniczny czas oczekiwania w kolejce");
- d1.add(mvWaitingTime, java.awt.Color.GREEN);
- d1.show();
- System.out.println("SimModel: Simulation finished");
- LOGGER.info("Koniec symulacji");
- }
- public static LinkedList<Cashier> generateCashiers(int l) {
- LinkedList<Cashier> tmp = new LinkedList<>();
- for (int i = 1; i <= l; i++) {
- Cashier c = new Cashier(i);
- tmp.add(c);
- }
- return tmp;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement