Package jmt.analytical

Examples of jmt.analytical.SolverAlgorithm


  private void paintIndexAtRow(int rowNum) {
    // Clears previous graph
    graph.clear(rowNum);
    int classNum = classes[rowNum];
    int statNum = stations[rowNum];
    SolverAlgorithm alg = algorithms[rowNum];

    //Modified the below condition by ASHANKA for
    //System Power there is no Station Panel
    //in fact the station panel is removed
    //System Power is Indices type 4
View Full Code Here


        //Added by ASHANKA STOP
        selector.addSolutionPanel(algPanel);
      }
      jtp.add(selector);
    } else if (selector != null && data.isClosed()) {
      SolverAlgorithm algorithm = data.getAlgorithmType();
      AlgorithmPanel algPanel = new AlgorithmPanel(this, algorithm);
      algPanel.addSolutionPanel(new ThroughputPanel(this, algorithm));
      algPanel.addSolutionPanel(new QueueLenPanel(this, algorithm));     
      algPanel.addSolutionPanel(new ResTimePanel(this, algorithm));
      algPanel.addSolutionPanel(new SystemRespTimePanel(this, algorithm));
      algPanel.addSolutionPanel(new UtilizationPanel(this, algorithm));
      //Added by ASHANKA START
      // for System Power
      algPanel.addSolutionPanel(new SysPowerPanel(this, algorithm));
      //Added by ASHANKA STOP
      selector.addSolutionPanel(algPanel);
      /*
      selector.addSolutionPanel(throughput);
      selector.addSolutionPanel(queuelength);
      selector.addSolutionPanel(restimes);
      selector.addSolutionPanel(utilizations);
      //Added by ASHANKA START
      // for System Power
      selector.addSolutionPanel(systemPower);
      */
      //Added by ASHANKA STOP
      jtp.add(selector);
    } else if (selector != null) {
      SolverAlgorithm algorithm = data.getAlgorithmType();
      selector.addSolutionPanel(new ThroughputPanel(this, algorithm));
      selector.addSolutionPanel(new QueueLenPanel(this, algorithm));
      selector.addSolutionPanel(new ResTimePanel(this, algorithm));
      selector.addSolutionPanel(new SystemRespTimePanel(this, algorithm));
      selector.addSolutionPanel(new UtilizationPanel(this, algorithm));
      //Added by ASHANKA START
      // for System Power
      selector.addSolutionPanel(new SysPowerPanel(this, algorithm));
      //Added by ASHANKA STOP
      jtp.add(selector);
    } else {
      SolverAlgorithm alg = data.getAlgorithmType();
      ThroughputPanel throughput = new ThroughputPanel(this, alg);
      QueueLenPanel queuelength = new QueueLenPanel(this, alg);
      ResTimePanel restimes = new ResTimePanel(this, alg);
      SystemRespTimePanel systemreptime = new SystemRespTimePanel(this,alg);
      UtilizationPanel utilizations = new UtilizationPanel(this, alg);
View Full Code Here

      Element compareAlgs = (Element) algParam.getElementsByTagName("compareAlgs").item(0);
      NodeList whatIfAlgs = compareAlgs.getElementsByTagName("whatIfAlg");
      for (int i = 0; i < whatIfAlgs.getLength(); i++) {
        Element alg = (Element) whatIfAlgs.item(i);
        String name = alg.getAttribute("name");
        SolverAlgorithm algo = SolverAlgorithm.fromString(name);
        this.setWhatifAlgorithm(algo, true);
        this.setWhatifAlgorithmTolerance(algo, Double.parseDouble(alg.getAttribute("tolerance")));
      }
    } else {
      this.whatifAlgorithms = EnumSet.noneOf(SolverAlgorithm.class);
View Full Code Here

      if (solution.hasAttribute("algCount")) {
        /* EDITED by Abhimanyu Chugh */
        int algCount = Integer.parseInt(solution.getAttribute("algCount"));
        for (int a = 0; a < algCount; a++) {
          Element a_alg = (Element) solution.getElementsByTagName("algorithm").item(a);
          SolverAlgorithm alg = SolverAlgorithm.fromString(a_alg.getAttribute("name"));
         
          if (alg == null) {
            continue;
          }
          boolean isApprox = !alg.isExact();
          if (i == 0) {
            queueLen.put(alg, new double[stations][classes][iterations]);
            throughput.put(alg, new double[stations][classes][iterations]);
            resTimes.put(alg, new double[stations][classes][iterations]);
            util.put(alg, new double[stations][classes][iterations]);
            if (isApprox) {
              algIterations.put(alg, new int[iterations]);
            }
          }
         
          ArrayUtils.copy2to3(loadResultsMatrix(a_alg, stations, classes, "Number of Customers"), queueLen.get(alg), i);
          ArrayUtils.copy2to3(loadResultsMatrix(a_alg, stations, classes, "Throughput"), throughput.get(alg), i);
          ArrayUtils.copy2to3(loadResultsMatrix(a_alg, stations, classes, "Residence time"), resTimes.get(alg), i);
          ArrayUtils.copy2to3(loadResultsMatrix(a_alg, stations, classes, "Utilization"), util.get(alg), i);
          if (isApprox) {
            int algIters = Integer.parseInt(a_alg.getAttribute("iterations"));
            algIterations.get(alg)[i] = algIters;
          }
        }
        /* END */
      } else {
        SolverAlgorithm alg = SolverAlgorithm.EXACT;

        if (i == 0) {
          queueLen.put(alg, new double[stations][classes][iterations]);
          throughput.put(alg, new double[stations][classes][iterations]);
          resTimes.put(alg, new double[stations][classes][iterations]);
View Full Code Here

    }
    if (!data.isClosed()) {
      compMultiAlg.setEnabled(false);
    }
    for (Entry<SolverAlgorithm, JCheckBox> e : this.algCheckBoxes.entrySet()) {
      SolverAlgorithm algo = e.getKey();
      boolean selected = (data.getWhatifAlgorithms().contains(algo));
      JCheckBox checkbox = e.getValue();
      if ((selected && !checkbox.isSelected()) || (!selected && checkbox.isSelected())) {
        checkbox.doClick();
      }
      if (!data.isClosed()) {
        checkbox.setEnabled(false);
      }
      if (!algo.isExact()) {
        algTolerances.get(algo).setText(numFormat.format(data.getWhatifAlgorithmTolerance(algo)));
        if (!data.isClosed()) {
          algToleranceLabels.get(algo).setEnabled(false);
          algTolerances.get(algo).setEnabled(false);
        }
View Full Code Here

    algCheckBoxes = new EnumMap<SolverAlgorithm, JCheckBox>(SolverAlgorithm.class);
    algTolerances = new EnumMap<SolverAlgorithm, JTextField>(SolverAlgorithm.class);
    algToleranceLabels = new EnumMap<SolverAlgorithm, JLabel>(SolverAlgorithm.class);
    int noOfExactAlgs = SolverAlgorithm.noOfExactAlgs();
    for (int i = 0; i < SolverAlgorithm.closedValues().length; i++) {
      SolverAlgorithm algo = SolverAlgorithm.closedValues()[i];
      if (i == 0) {
        JLabel label = new JLabel("--------- Exact ---------");
        label.setMinimumSize(new Dimension(250, 0));
        algPanel.add(label, BorderLayout.CENTER);
        label.setForeground(Color.DARK_GRAY);
        label.setFocusable(false);
        JPanel placeholder = new JPanel();
        placeholder.setFocusable(false);
        algPanel.add(placeholder);
      } else if (i == noOfExactAlgs) {
        JLabel label = new JLabel("----- Approximate -----");
        label.setMinimumSize(new Dimension(250, 0));
        algPanel.add(label, BorderLayout.CENTER);
        label.setForeground(Color.DARK_GRAY);
        label.setFocusable(false);
        JPanel placeholder = new JPanel();
        placeholder.setFocusable(false);
        algPanel.add(placeholder);
      }
     
      JCheckBox checkBox = new JCheckBox (algo.toString());
      checkBox.setName(algo.toString());

      final int index = i;
      checkBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          AbstractButton abstractButton = (AbstractButton) e.getSource();
          boolean selected = abstractButton.getModel().isSelected();
          SolverAlgorithm algorithm = SolverAlgorithm.fromString(abstractButton.getName());
          data.setWhatifAlgorithm(algorithm, selected);
        }
      });
     
      algPanel.add(checkBox);
      algCheckBoxes.put(algo,checkBox);
     
      if (!algo.isExact()) {
        Dimension d = new Dimension(70,30);
        JLabel tolLabel = new JLabel("Tolerance: ");
        tolLabel.setMaximumSize(d);
        tolLabel.setFocusable(false);
        d = new Dimension(90,30);
        JTextField tolerance = new JTextField(30);
        tolerance.setText(numFormat.format(SolverMultiClosedAMVA.DEFAULT_TOLERANCE));
        tolerance.setMaximumSize(d);
        tolerance.setName(algo.toString());
        tolerance.addFocusListener(new FocusListener() {
          @Override
          public void focusLost(FocusEvent e) {
            JTextField textField = (JTextField) e.getSource();
            Double tol = SolverMultiClosedAMVA.validateTolerance(textField.getText());
            SolverAlgorithm algorithm = SolverAlgorithm.fromString(textField.getName());
            if (tol != null) {
              data.setWhatifAlgorithmTolerance(algorithm, tol);
            }
            else {
              JOptionPane.showMessageDialog(WhatIfPanel.this, "Error: Invalid tolerance value. Using last valid value.", "Input data error", JOptionPane.ERROR_MESSAGE);
            }
          }
         
          @Override
          public void focusGained(FocusEvent e) {
          }
        });
        tolerance.addKeyListener(new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
              JTextField textField = (JTextField) e.getSource();
              SolverAlgorithm algorithm = SolverAlgorithm.fromString(textField.getName());
              Double tol = SolverMultiClosedAMVA.validateTolerance(textField.getText());
              if (tol != null) {
                data.setWhatifAlgorithmTolerance(algorithm, tol);
              }
              else {
View Full Code Here

   * @param isAlgowhatif true if whatif on algorithm was selected, false if not, null to read from data structure
   * @param isLoadDependent if model is load dependent or not. null to read from data structure
   */
  public void update(Boolean isClosed, Boolean isOpen, Boolean isAlgowhatif, Boolean isLoadDependent) {
    ExactModel data = ew.getData();
    SolverAlgorithm algorithm = data.getAlgorithmType();
    tolerance.setText(numFormat.format(data.getTolerance()));
    algorithmList.setSelectedItem(algorithm.toString());
    if (isClosed == null) {
      isClosed = ew.getData().isClosed();
    }
    if (isOpen == null) {
      isOpen = ew.getData().isOpen();
    }
    if (isAlgowhatif == null) {
      isAlgowhatif = ew.getData().isWhatifAlgorithms();
    }
    if (isLoadDependent == null) {
      isLoadDependent = ew.getData().isLd();
    }
   
    if (isLoadDependent) {
      updateStatus(PanelStatus.DISABLED_MIXED);
    } else if (isAlgowhatif) {
      updateStatus(PanelStatus.DISABLED_WHATIF);
    } else if (isOpen) {
      updateStatus(PanelStatus.DISABLED_OPEN);
    } else if (!isClosed) {
      updateStatus(PanelStatus.DISABLED_MIXED);
    } else if (!algorithm.isExact()) {
      updateStatus(PanelStatus.ENABLED_TOL);
    } else {
      updateStatus(PanelStatus.ENABLED);
    }
  }
View Full Code Here

TOP

Related Classes of jmt.analytical.SolverAlgorithm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.