Examples of InputDataException


Examples of jmt.common.exception.InputDataException

        int pop = model.getMaxpop();
        //First of all controls that the closed class has population greater than 0.
        //Otherwise throws a InputDataException
        if (pop <= 0) {
          //error: population is not greater than 0.0
          throw new InputDataException("Population must be greater than zero");
        }
       
        /** Edited by Abhimanyu Chugh **/
        if (SolverAlgorithm.EXACT.equals(algorithmType)) {
          solver = new SolverSingleClosedMVA(pop, stations);
        /*} else if (SolverAlgorithm.MoM.equals(algorithmType)) {
          solver = new SolverSingleClosedMoM(pop, stations);
        */} else {
          SolverAlgorithm algType = model.getAlgorithmType();
          solver = new SolverSingleClosedAMVA(pop, stations, algType, model.getTolerance());
        }
        /** End **/
       
        if (!solver.input(names, types, servicetimes, visits)) {
          /** Edited by Abhimanyu Chugh **/
          String algName = algorithmType.toString().replace(" ", "").replace("-", "");
          fail("Error initializing " + algName + "SingleSolver", null);
          //fail("Error initializing MVASolver", null);
          /** End **/
        }
      } else {
        /** Edited by Abhimanyu Chugh **/
        algorithmType = SolverAlgorithm.EXACT;
        /** End **/
        //TODO this is not used any more (multi solver is used instead)
        /* single open */
        double lambda = (model.getClassData())[0];
        //First of all controls that the open class has rate greater than 0.
        //Otherwise throws a InputDataException
        if (lambda <= 0) {
          //error: rate is not greater than 0.0
          throw new InputDataException("Arrival rate must be greater than zero");

        }
        solver = new SolverSingleOpen(model.getClassData()[0], stations);
        if (!solver.input(names, types, servicetimes, visits)) {
          fail("Error initializing OpenSolver", null);
        }
      }
    } catch (Exception e) {
      fail("Error initializing SingleClass solver", e);
    }
    //controls processing capacity
    if (!solver.hasSufficientProcessingCapacity()) {
      throw new InputDataException("One or more resources are in saturation. Decrease arrival rates or service demands.");
    }

    /* solve */
    solver.solve();
   
 
View Full Code Here

Examples of jmt.common.exception.InputDataException

        //error: population or rate not greater than 0.0
        //prepare message according to model type (mixed, open or closed)

        if (model.isMixed()) {
          //mixed model -> populations or rates
          throw new InputDataException("Populations and arrival rates must be greater than zero");
        } else if (model.isOpen()) {
          //open model -> rates
          throw new InputDataException("Arrival rates must be greater than zero");
        } else {
          //closed model -> populations
          throw new InputDataException("Populations must be greater than zero");
        }

      }
    }

    /* init */
    try {
      if (model.isOpen()) {
        /** Edited by Abhimanyu Chugh **/
        algorithmType = SolverAlgorithm.EXACT;
        /** End **/
        solver = new SolverMultiOpen(classes, stations, model.getClassData(), model.getStationServers());
        if (!solver.input(stationNames, stationTypes, serviceTimes, visits)) {
          fail("Error initializing SolverMultiOpen", null);
        }
      } else {
        if (model.isClosed()) {
          /** Edited by Abhimanyu Chugh **/
          if (SolverAlgorithm.EXACT.equals(algorithmType)) {
            SolverMultiClosedMVA closedsolver = new SolverMultiClosedMVA(classes, stations);
            if (!closedsolver.input(stationNames, stationTypes, serviceTimes, visits, classPop)) {
              fail("Error initializing MVAMultiSolver", null);
            }
            solver = closedsolver;
          } else if (SolverAlgorithm.RECAL.equals(algorithmType)) {
            int nThreads = 1;
            SolverMultiClosedRECAL closedSolver = new SolverMultiClosedRECAL(classes, stations, classPop);
            if (!closedSolver.input(stationTypes, serviceTimes, visits, nThreads)) {
                fail("Error initializing RECALMultiSolver", null);
            }
            solver = closedSolver;
          } else if (SolverAlgorithm.MOM.equals(algorithmType)) {
            int nThreads = 1;
            SolverMultiClosedMoM closedSolver = new SolverMultiClosedMoM(classes, stations, classPop);
            if (!closedSolver.input(stationTypes, serviceTimes, visits, nThreads)) {
                fail("Error initializing MoMMultiSolver", null);
            }
            solver = closedSolver;
          } else if (SolverAlgorithm.COMOM.equals(algorithmType)) {
            int nThreads = 1;
            SolverMultiClosedCoMoM closedSolver = new SolverMultiClosedCoMoM(classes, stations, classPop);
            if (!closedSolver.input(stationTypes, serviceTimes, visits, nThreads)) {
                fail("Error initializing CoMoMMultiSolver", null);
            }
            solver = closedSolver;
          } else {
            double tolerance = model.getTolerance();
            SolverMultiClosedAMVA closerSolver = null;
            if (SolverAlgorithm.CHOW.equals(algorithmType)) {
              closerSolver = new SolverMultiClosedChow(classes, stations, classPop);
            } else if (SolverAlgorithm.BARD_SCHWEITZER.equals(algorithmType)) {
              closerSolver = new SolverMultiClosedBardSchweitzer(classes, stations, classPop);
            } else if (SolverAlgorithm.AQL.equals(algorithmType)) {
              closerSolver = new SolverMultiClosedAQL(classes, stations, classPop);
            } else {
              closerSolver = new SolverMultiClosedLinearizer(classes, stations, classPop, SolverAlgorithm.DESOUZA_MUNTZ_LINEARIZER.equals(algorithmType));
            }
            ((SolverMultiClosedAMVA)closerSolver).setTolerance(tolerance);
           
            if (!closerSolver.input(stationNames, stationTypes, serviceTimes, visits)) {
              String algName = algorithmType.toString().replace(" ", "").replace("-", "");
              fail("Error initializing " + algName + "MultiSolver", null);
            }
            solver = closerSolver;
          }
          /** End **/
     
        } else {
          //model is multiclass mixed
          /** Edited by Abhimanyu Chugh **/
          algorithmType = SolverAlgorithm.EXACT;
          /** End **/
          int[] classTypes = mapClassTypes(model.getClassTypes());

          SolverMultiMixed mixedsolver = new SolverMultiMixed(classes, stations);
          if (!mixedsolver.input(stationNames, stationTypes, serviceTimes, visits, classData, classTypes)) {
            fail("Error initializing SolverMultiMixed", null);
          }
          solver = mixedsolver;
        }
      }
    } catch (Exception e) {
      fail("Error initializing Multiclass solver", e);
    }
    if (!solver.hasSufficientProcessingCapacity()) {
      throw new InputDataException("One or more resources are in saturation. Decrease arrival rates or service demands.");
    }
   
    long start = System.currentTimeMillis();
   
    /* solution */
 
View Full Code Here

Examples of jmt.common.exception.InputDataException

   * @param model input model
   */
  private void whatIfArrival(ExactModel model) throws SolverException, InputDataException {
    // Sanity checks on input model.
    if (model.getWhatIfClass() >= 0 && model.getClassTypes()[model.getWhatIfClass()] != ExactConstants.CLASS_OPEN) {
      throw new InputDataException("Cannot change arrival rate of a closed class.");
    }
    if (model.isClosed()) {
      throw new InputDataException("Cannot change arrival rates in a closed model.");
    }

    // Values for what-if
    double[] values = model.getWhatIfValues();

View Full Code Here

Examples of jmt.common.exception.InputDataException

   * @param model input model
   */
  private void whatIfCustomers(ExactModel model) throws SolverException, InputDataException {
    // Sanity checks on input model.
    if (model.getWhatIfClass() >= 0 && model.getClassTypes()[model.getWhatIfClass()] != ExactConstants.CLASS_CLOSED) {
      throw new InputDataException("Cannot change number of customers of an open class.");
    }
    if (model.isOpen()) {
      throw new InputDataException("Cannot change number of customers in an open model.");
    }

    // Values for what-if
    double[] values = model.getWhatIfValues();

    // Backup class datas
    double[] initials = model.getClassData().clone();

    // Iterates for what-if executions
    int i;
    for (i = 0; i < model.getWhatIfValues().length && !stopped; i++) {
      double[] current = initials.clone();
      // If this is one class only
      if (model.getWhatIfClass() >= 0) {
        current[model.getWhatIfClass()] = values[i];
        // Check for not integer values
        if (Math.abs(current[model.getWhatIfClass()] - Math.rint(current[model.getWhatIfClass()])) > 1e-8) {
          throw new InputDataException("A fractional population value was assigned to class "
              + model.getClassNames()[model.getWhatIfClass()] + " during step " + i);
        }
        // Rounds number to avoid truncation problems
        current[model.getWhatIfClass()] = Math.round(current[model.getWhatIfClass()]);

      }
      // If this is all closed classes
      else {
        for (int j = 0; j < current.length; j++) {
          if (model.getClassTypes()[j] == ExactConstants.CLASS_CLOSED) {
            current[j] = initials[j] * values[i];
            // Check for not integer values
            if (Math.abs(current[j] - Math.rint(current[j])) > 1e-8) {
              throw new InputDataException("A fractional population value was assigned to class " + model.getClassNames()[j]
                  + " during step " + i);
            }
            // Rounds number to avoid truncation problems
            current[j] = Math.round(current[j]);
          }
View Full Code Here

Examples of jmt.common.exception.InputDataException

   * @param model input model
   */
  private void whatIfDemands(ExactModel model) throws SolverException, InputDataException {
    // Sanity checks on input model.
    if (model.getWhatIfStation() < 0 || model.getWhatIfStation() >= model.getStations()) {
      throw new InputDataException("Station for what-if analysis not specified.");
    }
    if (model.getStationTypes()[model.getWhatIfStation()] == ExactConstants.STATION_LD) {
      throw new InputDataException("Service Demands what-if analysis not supported on Load Dependent stations.");
    }

    // Values for what-if
    double[] values = model.getWhatIfValues();

View Full Code Here

Examples of jmt.common.exception.InputDataException

  private void whatIfMix(ExactModel model) throws SolverException, InputDataException {
    // First and second closed class for population mix what-if
    int class1, class2 = -1;
    class1 = model.getWhatIfClass();
    if (class1 < 0) {
      throw new InputDataException("Class not specified for population mix what-if analysis.");
    }
    // Find second class
    for (int i = 0; i < model.getClasses(); i++) {
      if (model.getClassTypes()[i] == ExactConstants.CLASS_CLOSED && i != class1) {
        if (class2 < 0) {
          class2 = i;
        } else {
          throw new InputDataException("Only models with two closed classes are supported. More than two classes detected.");
        }
      }
    }
    if (class2 < 0) {
      throw new InputDataException("Only models with two closed classes are supported. Only one classes detected.");
    }

    // Values for what-if
    double[] values = model.getWhatIfValues();

    // Backup class datas
    double[] initials = model.getClassData().clone();

    // Value for total number of customer
    double N = initials[class1] + initials[class2];

    // Iterates for what-if executions
    int i;
    for (i = 0; i < model.getWhatIfValues().length && !stopped; i++) {
      double[] current = initials.clone();
      current[class1] = values[i] * N;
      current[class2] = (1 - values[i]) * N;
      // Check for not integer values
      if (Math.abs(current[class1] - Math.rint(current[class1])) > 1e-8) {
        throw new InputDataException("A fractional population value was assigned to class " + model.getClassNames()[class1] + " during step "
            + i);
      } else if (Math.abs(current[class2] - Math.rint(current[class2])) > 1e-8) {
        throw new InputDataException("A fractional population value was assigned to class " + model.getClassNames()[class2] + " during step "
            + i);
      }
      // Rounds number to avoid truncation problems
      current[class1] = Math.round(current[class1]);
      current[class2] = Math.round(current[class2]);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.