Class ExactModel

java.lang.Object
analytical.ExactModel
All Implemented Interfaces:
ExactConstants

public class ExactModel extends Object implements ExactConstants
Model data structure of the exact JMVA algorithms: classes, stations, service demands and reference stations of a product form queueing network.
  • Field Details

  • Constructor Details

    • ExactModel

      public ExactModel()
      make an object with default values
    • ExactModel

      public ExactModel(ExactModel e)
      copy constructor
  • Method Details

    • getAlgorithmType

      public SolverAlgorithm getAlgorithmType()
    • setAlgorithmType

      public void setAlgorithmType(SolverAlgorithm algType)
    • getTolerance

      public double getTolerance()
    • setTolerance

      public void setTolerance(double tol)
    • getMaxSamples

      public int getMaxSamples()
    • setMaxSamples

      public void setMaxSamples(int mSamples)
    • getWhatifAlgorithms

      public Set<SolverAlgorithm> getWhatifAlgorithms()
      Returns the whatif algorithms.
      Returns:
      the set of algorithm to perform whatif on
    • setWhatifAlgorithm

      public void setWhatifAlgorithm(SolverAlgorithm algorithm, boolean compare)
      Set algorithm to perform whatif on
      Parameters:
      algorithm - the algorithm
      compare - true to do whatif, false otherwise
    • getWhatifAlgorithmTolerance

      public double getWhatifAlgorithmTolerance(SolverAlgorithm algorithm)
      Returns the tolerance for a whatif algorithm
      Parameters:
      algorithm - the algorithm
      Returns:
      the tolerance
    • setWhatifAlgorithmTolerance

      public void setWhatifAlgorithmTolerance(SolverAlgorithm algorithm, double value)
      Sets the tolerance for a whatif algorithm
      Parameters:
      algorithm - the algorithm
      value - the tolerance
    • getWhatifAlgorithmMaxSamples

      public int getWhatifAlgorithmMaxSamples(SolverAlgorithm algorithm)
      Returns the max samples for a whatif algorithm
      Parameters:
      algorithm - the algorithm
      Returns:
      the max samples
    • setWhatifAlgorithmMaxSamples

      public void setWhatifAlgorithmMaxSamples(SolverAlgorithm algorithm, int value)
      Sets the max samples for a whatif algorithm
      Parameters:
      algorithm - the algorithm
      value - the max samples
    • isWhatifAlgorithms

      public boolean isWhatifAlgorithms()
      Checks whether whatif algorithms.
      Returns:
      true if AMVA algorithm comparison was requested. false otherwise.
    • clearWhatifAlgorithms

      public void clearWhatifAlgorithms()
      Clears whatif algorithms selection
    • getIterations

      public int getIterations()
    • discardResults

      public void discardResults()
      Clears all the results
    • discardChanges

      public void discardChanges()
      Discards all change elements but does not touch results
    • setResults

      public void setResults(SolverAlgorithm alg, int[] algIterations, double[][][] queueLen, double[][][] throughput, double[][][] resTimes, double[][][] util, double logNormConst)
      sets all the result data for this model.
      Parameters:
      alg - the alg
      algIterations - the alg iterations
      queueLen - the queue len
      throughput - the throughput
      resTimes - the res times
      util - the util
      logNormConst - the log norm const
      Throws:
      IllegalArgumentException - if any argument is null or not of the correct size
    • setResults

      public void setResults(SolverAlgorithm alg, int algIterations, double[][] queueLen, double[][] throughput, double[][] resTimes, double[][] util, double logNormConst)
      sets all the result data for this model. This is called when only one iteration is performed.
      Parameters:
      alg - the alg
      algIterations - the alg iterations
      queueLen - the queue len
      throughput - the throughput
      resTimes - the res times
      util - the util
      logNormConst - the log norm const
      Throws:
      IllegalArgumentException - if any argument is null or not of the correct size
    • setResultsOK

      public void setResultsOK(boolean value)
      Sets ResultsOK flag
      Parameters:
      value - value of ResultsOK flag
    • setResults

      public void setResults(SolverAlgorithm alg, int algIterations, double[][] queueLen, double[][] throughput, double[][] resTimes, double[][] util, double logNormConst, int iteration)
      sets all the result data for this model. This is called on multiple iterations (what-if analysis)
      Parameters:
      alg - the alg
      algIterations - the alg iterations
      queueLen - the queue len
      throughput - the throughput
      resTimes - the res times
      util - the util
      logNormConst - the log norm const
      iteration - the iteration
      Throws:
      IllegalArgumentException - if any argument is null or not of the correct size
    • setResultsBooleans

      public void setResultsBooleans(boolean value)
    • resetAlgResults

      public void resetAlgResults(SolverAlgorithm alg)
      Resets a particular algorithm's arrays used to store results
    • resetAlgResults

      public void resetAlgResults()
      Resets all algorithms' arrays used to store results
    • resetResults

      public void resetResults()
      Resets arrays used to store results
    • setDefaults

      public void setDefaults()
      Initialize the object with defaults: 1 closed class, 1 LI station, 0 customers, all visits to one, all service times to zero, no results
    • getDescription

      public String getDescription()
      Gets the model description
      Returns:
      the model description
    • setDescription

      public boolean setDescription(String description)
      Sets the model description
      Parameters:
      description - the model description
      Returns:
      true if data was changed, false otherwise
    • isSingleClass

      public boolean isSingleClass()
      Checks whether single class.
      Returns:
      true if this object describes a single class system
    • isMultiClass

      public boolean isMultiClass()
      Checks whether multi class.
      Returns:
      true if this object describes a multiclass system
    • isClosed

      public boolean isClosed()
      Checks whether closed.
      Returns:
      true if this object describes a closed system
    • isOpen

      public boolean isOpen()
      Checks whether open.
      Returns:
      true if this object describes an open system
    • isMixed

      public boolean isMixed()
      Checks whether mixed.
      Returns:
      true if this object describes a mixed system
    • isLd

      public boolean isLd()
      Checks whether ld.
      Returns:
      true if this object describes a system containing LD stations
    • isPriority

      public boolean isPriority()
      Checks whether priority.
      Returns:
      true if this object describes a system containing priority stations
    • getStations

      public int getStations()
      Returns the stations.
      Returns:
      number of service centers
    • getClasses

      public int getClasses()
      Returns the classes.
      Returns:
      number of classes
    • getReferenceStation

      public int[] getReferenceStation()
      Returns the reference station.
      Returns:
      get the matrix of ReferenceStations
    • getTotalPop

      public int getTotalPop()
      Returns the total pop.
      Returns:
      total population
    • getStationNames

      public String[] getStationNames()
      Returns the station names.
      Returns:
      names of the service centers
    • getStationServers

      public int[] getStationServers()
      Returns the station servers.
      Returns:
      the number of servers for each station. For delay stations this parameter is unsensed.
    • isMultipleServers

      public boolean isMultipleServers()
      Checks whether multiple servers.
      Returns:
      true if this model contains multiple server for a station.
    • setStationServers

      public boolean setStationServers(int[] stationServers)
      sets the number of servers for each station
      Parameters:
      stationServers - the number of servers of each station
      Returns:
      true if data was changed, false otherwise
      Throws:
      IllegalArgumentException - if the array is not of the correct size
    • setStationNames

      public boolean setStationNames(String[] stationNames)
      sets the names of the service centers.
      Parameters:
      stationNames - the names of the service centers
      Returns:
      true if data was changed, false otherwise
      Throws:
      IllegalArgumentException - if the array is not of the correct size
    • getClassNames

      public String[] getClassNames()
      Returns the class names.
      Returns:
      names of the classes
    • setClassNames

      public boolean setClassNames(String[] classNames)
      sets the names of the classes.
      Parameters:
      classNames - the names of the classes
      Returns:
      true if data was changed, false otherwise
      Throws:
      IllegalArgumentException - if the array is not of the correct size
    • getClassData

      public double[] getClassData()
      Returns the class data.
      Returns:
      data for the classes.
    • setClassData

      public boolean setClassData(double[] classData)
      sets the data for the classes
      Parameters:
      classData - the data for the classes
      Returns:
      true if data was changed, false otherwise
      Throws:
      IllegalArgumentException - if the array is not of the correct size
    • getClassTypes

      public int[] getClassTypes()
      Returns the class types.
      Returns:
      type of the classes
    • setClassTypes

      public boolean setClassTypes(int[] classTypes)
      sets the type of the classes
      Parameters:
      classTypes - the type of the classes
      Returns:
      true if data was changed, false otherwise
      Throws:
      IllegalArgumentException - if the array is not of the correct size
    • getClassPriorities

      public int[] getClassPriorities()
      Returns the class priorities.
      Returns:
      priorities of the classes
    • setClassPriorities

      public boolean setClassPriorities(int[] classPriorities)
      sets the priorities of the classes
      Parameters:
      classPriorities - the priority of the classes
      Returns:
      true if data was changed, false otherwise
      Throws:
      IllegalArgumentException - if the array is not of the correct size
    • getStationTypes

      public int[] getStationTypes()
      Returns the station types.
      Returns:
      type of the stations
    • setStationTypes

      public boolean setStationTypes(int[] stationTypes)
      sets the type of the stations
      Parameters:
      stationTypes - the type of the stations
      Returns:
      true if data was changed, false otherwise
      Throws:
      IllegalArgumentException - if the array is not of the correct size
    • getVisits

      public double[][] getVisits()
      Returns the visits.
      Returns:
      the matrix of visits
    • setVisits

      public boolean setVisits(double[][] visits)
      sets the matrix of visits
      Parameters:
      visits - the matrix of visits
      Returns:
      true if data was changed, false otherwise
      Throws:
      IllegalArgumentException - if the matrix is not of the correct size
    • getServiceTimes

      public double[][][] getServiceTimes()
      Returns the service times.
      Returns:
      the matrix of service times
    • setServiceTimes

      public boolean setServiceTimes(double[][][] serviceTimes)
      sets the matrix of service times
      Parameters:
      serviceTimes - the matrix of service times
      Returns:
      true if data was changed, false otherwise
      Throws:
      IllegalArgumentException - if the matrix is not of the correct size
    • setReferenceStation

      public boolean setReferenceStation(int[] ReferenceStation)
      sets the matrix of ReferenceStation
      Parameters:
      ReferenceStation - the matrix of ReferenceStation
      Returns:
      true if data was changed, false otherwise
      Throws:
      IllegalArgumentException - if the matrix is not of the correct size
    • resize

      public boolean resize(int stations, int classes, boolean forceResize)
      Resizes the data structures according to specified parameters. Data is preserved as far as possible
      Parameters:
      stations - the stations
      classes - the classes
      forceResize - the force resize
      Returns:
      true if data was changed, false otherwise
    • resize

      public boolean resize(int stations, int classes)
      Resizes the data structures according to specified parameters. Data is preserved as far as possible
      Parameters:
      stations - the stations
      classes - the classes
      Returns:
      true if data was changed, false otherwise
    • getAlgIterations

      public Map<SolverAlgorithm, int[]> getAlgIterations()
      Returns:
      algorithm iterations
    • getAlgIterations

      public int[] getAlgIterations(SolverAlgorithm alg)
      Returns the alg iterations.
      Parameters:
      alg - the alg
      Returns:
      algorithm iterations for the given algorithm
    • getQueueLen

      public Map<SolverAlgorithm, double[][][]> getQueueLen()
      Returns:
      queue lengths
    • getQueueLen

      public double[][][] getQueueLen(SolverAlgorithm alg)
      Returns the queue len.
      Parameters:
      alg - the alg
      Returns:
      queue lengths for the given algorithm
    • getResidTimes

      public Map<SolverAlgorithm, double[][][]> getResidTimes()
      Returns:
      residence times
    • getResidTimes

      public double[][][] getResidTimes(SolverAlgorithm alg)
      Returns the resid times.
      Parameters:
      alg - the alg
      Returns:
      response times for the given algorithm
    • getRespTimes

      public double[][][] getRespTimes(SolverAlgorithm alg)
      Returns the resp times.
      Parameters:
      alg - the alg
      Returns:
      residence times for the given algorithm
    • getThroughput

      public Map<SolverAlgorithm, double[][][]> getThroughput()
      Returns:
      throughputs
    • getThroughput

      public double[][][] getThroughput(SolverAlgorithm alg)
      Returns the throughput.
      Parameters:
      alg - the alg
      Returns:
      throughputs for the given algorithm
    • getUtilization

      public Map<SolverAlgorithm, double[][][]> getUtilization()
      Returns:
      utilizations
    • getUtilization

      public double[][][] getUtilization(SolverAlgorithm alg)
      Returns the utilization.
      Parameters:
      alg - the alg
      Returns:
      utilizations for the given algorithm
    • getLogNormConst

      public Map<SolverAlgorithm, Double> getLogNormConst()
      Returns:
      logarithms of normalising constants
    • setLogNormConst

      public double setLogNormConst(SolverAlgorithm alg)
      Sets the log norm const.
      Parameters:
      alg - the alg
      Returns:
      logarithm of normalising constant for the given algorithm
    • removeLD

      public void removeLD()
      Removes all LD stations, converting them into LI stations
    • toString

      public String toString()
      Warning: Calling this on large systems *will* result in OutOfMemory errors. You have been warned.
      Overrides:
      toString in class Object
      Returns:
      a String representation of the parameters of this object
    • deleteClass

      public void deleteClass(int i)
      Deletes a class
      Parameters:
      i - the index of the class
    • deleteStation

      public void deleteStation(int i)
      Deletes a station
      Parameters:
      i - the index of the station
    • isChanged

      public boolean isChanged()
      Checks whether changed.
      Returns:
      true if the model has been changed
    • resetChanged

      public void resetChanged()
      resets the changed flag.
      WARNING: this enables change checking on parameter setting, which can be quite time-consuming.
    • setChanged

      public void setChanged()
      flags the model as changed. There is no need to call this, except to disable time-consuming change checking if you're not interested in it
    • hasResults

      public boolean hasResults()
      Checks whether results.
      Returns:
      true if results are available
    • areResultsOK

      public boolean areResultsOK()
      Method areResultsOK.
      Returns:
      true if results are valid
    • createDocument

      public Document createDocument()
      Creates a DOM representation of this object
      Returns:
      a DOM representation of this object
    • loadDocument

      public boolean loadDocument(Document doc)
      load the state of this object from the Document.
      Parameters:
      doc - the doc
      Returns:
      true if the operation was successful. WARNING: If the operation fails the object is left in an incorrect state and should be discarded.
    • loadDescription

      public boolean loadDescription(Element desc)
    • loadClasses

      public boolean loadClasses(Node classNode)
    • loadStations

      public boolean loadStations(Node stationNode)
    • loadReferenceStation

      public boolean loadReferenceStation(Node ReferenceStationNode)
    • loadReferenceStationDefault

      public boolean loadReferenceStationDefault(Node classNode)
    • loadSolution

      public boolean loadSolution(NodeList sol)
      Load solutions from xml file
      Parameters:
      sol - NodeList of solution elements
      Returns:
      true if load was successful, false otherwise
    • loadResultsMatrix

      public double[][] loadResultsMatrix(Element base, int len1, int len2, String res)
    • getPerClassX

      public double[][] getPerClassX(SolverAlgorithm alg)
      Returns per-class aggregate for throughput
    • getPerStationX

      public double[][] getPerStationX(SolverAlgorithm alg)
      Returns per-station aggregate for throughput
    • getGlobalX

      public double[] getGlobalX(SolverAlgorithm alg)
      Returns global aggregate for throughput
    • getPerClassQ

      public double[][] getPerClassQ(SolverAlgorithm alg)
      Returns per-class aggregate for queue length
    • getPerStationQ

      public double[][] getPerStationQ(SolverAlgorithm alg)
      Returns per-station aggregate for queue length
    • getGlobalQ

      public double[] getGlobalQ(SolverAlgorithm alg)
      Returns global aggregate for queue length
    • getPerClassR

      public double[][] getPerClassR(SolverAlgorithm alg, boolean with)
      Returns per-class aggregate for residence times
    • getPerStationRespT

      public double[][] getPerStationRespT(SolverAlgorithm alg)
      Returns per-station aggregate for response times
    • getPerStationResidT

      public double[][] getPerStationResidT(SolverAlgorithm alg)
      Returns per-station aggregate for residence times
    • getGlobalR

      public double[] getGlobalR(SolverAlgorithm alg, boolean with)
      Returns system response time
    • getPerStationU

      public double[][] getPerStationU(SolverAlgorithm alg)
    • getPerClassSP

      public double[][] getPerClassSP(SolverAlgorithm alg, boolean with)
    • getGlobalSP

      public double[] getGlobalSP(SolverAlgorithm alg, boolean with)
    • areVisitsSet

      public boolean areVisitsSet()
      This method tells if visits were set or are all unitary (or zero if corresponding service time is zero). This is used to show correct panel layout upon loading
      Returns:
      true iff visits were not set
    • randomizeModelData

      public void randomizeModelData()
      Randomizes model's service times and visits.
    • isWhatIf

      public boolean isWhatIf()
      Tells if this model includes a what-if analysis
      Returns:
      true if this model includes a what-if analysis
    • removeWhatIf

      public void removeWhatIf()
      Removes What-if analysis from current model
    • setWhatIfValues

      public boolean setWhatIfValues(double[] values)
      Sets the array of values used for what-if analysis
      Parameters:
      values - vector with values to be used in iterations of what-if analysis
      Returns:
      true if the operation is successful, false otherwise
    • setWhatIfClass

      public boolean setWhatIfClass(int classNum)
      Sets class used for what-if analysis
      Parameters:
      classNum - ordered number of selected class or -1 for every class
      Returns:
      true if data was changed, false otherwise
    • setWhatIfStation

      public boolean setWhatIfStation(int stationNum)
      Sets station used for what-if analysis
      Parameters:
      stationNum - ordered number of selected station or -1 for every station
      Returns:
      true if data was changed, false otherwise
    • setWhatIfType

      public boolean setWhatIfType(String type)
      Sets type of what-if analysis
      Parameters:
      type - WHAT_IF_ARRIVAL, WHAT_IF_CUSTOMERS, WHAT_IF_MIX, WHAT_IF_DEMANDS
      Returns:
      true if data was changed, false otherwise
      See Also:
    • getWhatIfType

      public String getWhatIfType()
      Returns type of what-if analysis
      Returns:
      WHAT_IF_ARRIVAL, WHAT_IF_CUSTOMERS, WHAT_IF_MIX, WHAT_IF_DEMANDS
      See Also:
    • getWhatIfStation

      public int getWhatIfStation()
      Returns index of station selected for what-if analysis or -1 if every station is selected
      Returns:
      index of station selected for what-if analysis or -1 if every station is selected
    • getWhatIfClass

      public int getWhatIfClass()
      Returns index of class selected for what-if analysis or -1 if every class is selected
      Returns:
      index of class selected for what-if analysis or -1 if every class is selected
    • getWhatIfValues

      public double[] getWhatIfValues()
      Returns the array of values used for what-if analysis
      Returns:
      the array of values used for what-if analysis
    • generateWhatIfValues

      public double[] generateWhatIfValues(String type, double from, double to, int iterations, int ClassRef, int stationRef)
      This method is used to generate a suitable vector of values for what-if analysis.
      Parameters:
      type - type of what-if analysis to be performed. (WHAT_IF_ARRIVAL, WHAT_IF_CUSTOMERS, WHAT_IF_MIX, WHAT_IF_DEMANDS)
      from - initial value
      to - final value
      iterations - expected number of iterations (will be adjusted to be compliant with specified from and to values in WHAT_IF_CUSTOMERS and WHAT_IF_MIX)
      ClassRef - index of class to be analyzed or -1 for all classes
      stationRef - index of station to be analyzed (only for WHAT_IF_DEMANDS)
      Returns:
      suitable array of iterations to be performed
    • recalculateWhatifValues

      public void recalculateWhatifValues()
      This method will recalculate whatif analysis values after the initial values were changed. At first detects changes, than applies modifications. If what-if analysis is no longer appliable, resets it.
    • checkSaturation

      public int checkSaturation()
      This function will check if one or more resources are in saturation. This will consider each iteration of what-if analysis if present.
      Returns:
      NO_SATURATION if everything is okay, SATURATION if a class saturation is detected with specified parameters and SATURATION_WHATIF if a saturation will be caused by whatif values.
    • checkVisitReferenceStation

      public boolean checkVisitReferenceStation()
      Checks current model for reference station consistency: all the visits of closed class in the reference station must be different from zero
      Returns:
      true if model is consistent, false otherwise
    • checkClassesReferenceStation

      public boolean checkClassesReferenceStation()
      Checks current model for reference station consistency: the reference station must be the same for all closed classes
      Returns:
      true if model is consistent, false otherwise