Package jmt.gui.exact

Examples of jmt.gui.exact.ExactModel


      }
    }

    classTable.stopEditing();

    ExactModel data = ew.getData();

    synchronized (data) {
      boolean whatIfChanged = false;
      if (hasDeletes) {
        //if at some point rows have been deleted
        //play back all ops in the same order on the data object
        playbackClassOps(data);
      } else {
        whatIfChanged |= data.resize(data.getStations(), classes); //otherwise a simple resize is ok
      }

      data.setClassNames(classNames);
      whatIfChanged |= data.setClassTypes(classTypes);
      whatIfChanged |= data.setClassData(classData);

      if (whatIfChanged) {
        data.recalculateWhatifValues();
      }

      sync();
    }
  }
View Full Code Here


    hasDeletes = false;
    stationOps.clear();

    /* sync status with data object */
    /* arrays are copied to ensure data object consistency is preserved */
    ExactModel data = ew.getData();
    synchronized (data) {
      stations = data.getStations();
      pop = data.getMaxpop();
      stationNames = ArrayUtils.copy(data.getStationNames());
      stationTypes = ArrayUtils.copy(data.getStationTypes());
    }

    stationSpinner.setValue(new Integer(stations));
  }
View Full Code Here

   * if true, load dependent stations are allowed
   * (at the moment, only single class closed models allow LD stations)
   * @return true if the model allows load dependent. False otherwise.
   */
  private boolean isLdEnabled() {
    ExactModel data = ew.getData();
    return data.isClosed() && !data.isMultiClass() && data.getAlgorithmType().supportLoadDependent() && !data.isWhatifAlgorithms();
  }
View Full Code Here

      }
    }

    stationTable.stopEditing();

    ExactModel data = ew.getData();
    synchronized (data) {

      if (hasDeletes) {
        playbackStationOps(data); //play back ops on the data object
      } else {
        data.resize(stations, data.getClasses());
      }
      data.setStationNames(stationNames);
      data.setStationTypes(stationTypes);

      //NEW
      //@author Stefano Omini
      sync();
      //end NEW
View Full Code Here

  /**
   * gets status from data object
   */
  public void sync() {
    /* arrays are copied to ensure data object consistency is preserved */
    ExactModel data = ew.getData();
    synchronized (data) {

      zeroLD = (data.isLd() && (data.getMaxpop() == 0));
      classes = data.getClasses();
      stations = data.getStations();

      classNames = data.getClassNames();
      stationNames = data.getStationNames();
      stationTypes = data.getStationTypes();

      serviceDemands = ArrayUtils.copy3per2(data.getServiceTimes(), data.getVisits());
    }
  }
View Full Code Here

  private void commit() {

    stTable.stopEditing();

    ExactModel data = ew.getData();
    synchronized (data) {
      boolean whatIfChanged = false;

      whatIfChanged |= data.setServiceTimes(serviceDemands);
      whatIfChanged |= data.setVisits(createUnitaryVisits());

      if (whatIfChanged) {
        data.recalculateWhatifValues();
      }
    }
  }
View Full Code Here

      if (checkForSave("<html>Save changes before switching?</html>")) {
        return;
      }
      // try {
      // New Converter by Bertoli Marco
      ExactModel output = new ExactModel();
      List res = ModelConverter.convertJSIMtoJMVA(model, output);
      ExactWizard jmva = new ExactWizard(output);
      // If problems are found, shows warnings
      if (res.size() > 0) {
        new WarningWindow(res, jmva, CommonConstants.JSIM, CommonConstants.JMVA).show();
View Full Code Here

  //assigns each component its own listener
  private void addListeners() {
    mvaAppl.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        new ExactWizard(new ExactModel());
        close();
      }
    });
    simAppl.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
View Full Code Here

    }

    /*********************SIM DEFINITION MODEL*********************/

    //Loads ExactModel and transforms it to CommonModel
    ExactModel exact = new ExactModel();
    XMLUtils xmlUtils = new XMLUtils();
    Document inputDoc;
    try {
      inputDoc = xmlUtils.loadXML(input);
      exact.loadDocument(inputDoc);
    } catch (SAXException e1) {
      logger.error("Cannot parse correctly input JMVA model: " + e1.getMessage());
      return null;
    } catch (IOException e1) {
      logger.error("I/O error opening input JMVA model: " + e1.getMessage());
      return null;
    }
    logger.debug("Input model opened correctly...");
    CommonModel simModel = new CommonModel();
    List<String> warnings = ModelConverter.convertJMVAtoJSIM(exact, simModel);
    // Last element of warning is transform matrix
    for (int i = 0; i < warnings.size(); i++) {
      logger.warn("Warning during conversion: " + warnings.get(i));
    }
    // Removes all measures from classes with null service demands
    removeNullMeasures(exact, simModel);
    logger.debug("Removed null measures from simulator model");

    Document modelDocument = XMLWriter.getDocument(simModel, outputModel);
    logger.debug("Converted JMVA xml to JSIM one");
    // Adds blocking region informations to model document
    NodeList blockingList = inputDoc.getElementsByTagName(XMLConstantNames.XML_E_REGION);
    // If model has one blocking region only, adds router to it (otherwise a job will exit from
    // region when it's not requested
    if (blockingList.getLength() == 1) {
      Element region = (Element) blockingList.item(0);
      Element router = inputDoc.createElement(XMLConstantNames.XML_E_REGIONNODE);
      router.setAttribute(XMLConstantNames.XML_A_REGIONNODE_NAME, "Router");
      region.insertBefore(router, region.getFirstChild());
    }
    Element root = modelDocument.getDocumentElement();
    NodeList preload = root.getElementsByTagName(XMLConstantNames.XML_E_PRELOAD);
    NodeList measures = root.getElementsByTagName(XMLConstantNames.XML_E_MEASURE);
    Node lastMeasure = measures.getLength() > 0 ? measures.item(measures.getLength() - 1) : null;
    for (int i = 0; i < blockingList.getLength(); i++) {
      Element imported = (Element) modelDocument.importNode(blockingList.item(i), true);
      String name = imported.getAttribute(XMLConstantNames.XML_A_REGION_NAME);
      if (preload.getLength() > 0) {
        root.insertBefore(imported, preload.item(0));
      } else {
        root.appendChild(imported);
      }
      // Adds blocking region measures
      Element dropRate = (Element) lastMeasure.cloneNode(true);
      dropRate.setAttribute(XMLConstantNames.XML_A_MEASURE_NODETYPE, XMLConstantNames.NODETYPE_REGION);
      dropRate.setAttribute(XMLConstantNames.XML_A_MEASURE_STATION, name);
      dropRate.setAttribute(XMLConstantNames.XML_A_MEASURE_TYPE, SimulationDefinition.MEASURE_DR);
      // For each class add drop rate measure
      for (int j = 0; j < exact.getClasses(); j++) {
        Element cloned = (Element) dropRate.cloneNode(true);
        cloned.setAttribute(XMLConstantNames.XML_A_MEASURE_CLASS, exact.getClassNames()[j]);
        cloned.setAttribute(XMLConstantNames.XML_A_MEASURE_NAME, exact.getClassNames()[j] + "_" + name + "_Drop Rate");
        root.insertBefore(cloned, lastMeasure);
        lastMeasure = cloned;
      }
    }
    logger.debug("Added finite capacity regions");
View Full Code Here

      simModelDefinitionPath = modelDefinitionParent + "sim_" + modelDefinition.getName();
    } else {
      simModelDefinitionPath = modelDefinitionParent + SEPARATOR + "sim_" + modelDefinition.getName();
    }

    ExactModel inputModel = getTransformedModel(modelDefinitionPath, simModelDefinitionPath);
    if (inputModel == null) {
      return false;
    }

    /*********************SIMULATION LOADING AND RUNNING*********************/

    //sim model successfully created
    //now prepare simulation
    try {
      SimLoader simLoader = new SimLoader(simModelDefinitionPath);
      Simulation sim = simLoader.getSim();
      //sim.MONITOR_BLOCKING_REGION = true;           
      //sets in the Simulation object the path of the original (i.e. MVA)
      //xml model definition
      sim.setXmlModelDefPath(modelDefinitionPath);

      if (!automaticSeed) {
        //if automaticSeed == false, then a user defined seed is present
        sim.setRandomEngineSeed(simulationSeed);
        sim.initialize();

        logger.debug("jSIM correctly initialized with simulation seed = " + simulationSeed);
      } else {
        sim.initialize();
        logger.debug("jSIM correctly initialized");
      }

      //Avoid saturation
      if (sim.getAllRegions() == null) {
        //if there are no regions...
        boolean sufficientProcessingCapacity = inputModel.checkSaturation() == ExactModel.NO_SATURATION;

        if (!sufficientProcessingCapacity) {
          logger.warn("Current workload causes system saturation. Simulation will not be started.");
          return false;
        }
View Full Code Here

TOP

Related Classes of jmt.gui.exact.ExactModel

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.