Class AdaptationMediator

java.lang.Object
adaptlil.mediator.Mediator
adaptlil.mediator.AdaptationMediator

public class AdaptationMediator extends Mediator
Loosely follows Mediator design pattern of a subsystem of components. It directs and controls how the adaptlil.adaptations are invoked and altered, how they are sent to the frontend, and the classification that occurs by analyzing the gaze window. TODO: Tidy up to better map # classifications/conditions -> rule-based selection process.
  • Field Details

    • websocket

      private VisualizationWebsocket websocket
    • gazepointSocket

      private GazepointSocket gazepointSocket
    • pythonServerCore

      private PythonServerCore pythonServerCore
    • gazeWindow

      private GazeWindow gazeWindow
    • isRunning

      private boolean isRunning
    • observedAdaptation

      private Adaptation observedAdaptation
    • currentAdaptations

      Map<String,Adaptation> currentAdaptations
    • thresholdForInvokation

      private double thresholdForInvokation
    • increaseStrengthThresh

      private double increaseStrengthThresh
    • remainThresh

      private double remainThresh
    • numSequencesForClassification

      private int numSequencesForClassification
    • newAdaptationStartSequenceIndex

      private int newAdaptationStartSequenceIndex
    • curSequenceIndex

      private int curSequenceIndex
    • defaultStrength

      private double defaultStrength
  • Constructor Details

  • Method Details

    • start

      public void start()
      Starts the entire adaptation mediator process. GazeWindow data will be collected, predicted on, then processed through rule-based selection process and finally an adaptation will be invoked.
    • countTaskFailurePredictionsAndInvokeAdaptation

      private void countTaskFailurePredictionsAndInvokeAdaptation(int[] classifications)
      Counts # task failure predictions and runs through the rule-based adaptation selection
      Parameters:
      classifications -
    • countTaskFailureClassifications

      private int countTaskFailureClassifications(int[] classifications)
      Counts Number of task success ocurrences (i.e. classification[i] == 1)
      Parameters:
      classifications -
      Returns:
    • classifyTaskSuccess

      public int classifyTaskSuccess(org.nd4j.linalg.api.ndarray.INDArray input)
      Classifies user's task success by sending the input to the python server and subsequently the deep learning model.
      Parameters:
      input - shape=(1,this.numSequencesForClassification, Gaze Attributes)
      Returns:
    • formatGazeWindowsToModelInput

      public org.nd4j.linalg.api.ndarray.INDArray formatGazeWindowsToModelInput(List<org.nd4j.linalg.api.ndarray.INDArray> gazeWindows)
      Formats collected gazewindows into the deep learning model's input format. Uses INDArray for better performance.
      Parameters:
      gazeWindows -
      Returns:
    • invokeNewAdaptationType

      public void invokeNewAdaptationType()
      Invokes a new type of adaptation and resets the state of the previous adaptation (so that if it circles back it starts at its default state)
    • adjustAdaptationStrengthAndInvoke

      public void adjustAdaptationStrengthAndInvoke()
    • getNewAdaptation

      private Adaptation getNewAdaptation()
      Get a new adaptation type
      Returns:
    • listOfAdaptations

      public List<Adaptation> listOfAdaptations()
      Returns the list of possible adaptation types.
      Returns:
    • runRuleBasedAdaptationSelectionProcess

      private void runRuleBasedAdaptationSelectionProcess(int numFailurePredictions)
      Rule-Based adaptation selection process that determines the appropriate action to take in terms of invoking a new adaptation type, adjusting adaptation strength, or doing nothing.
      Parameters:
      numFailurePredictions -
    • adaptationExists

      private boolean adaptationExists()
    • gracePeriodExpired

      private boolean gracePeriodExpired()
    • sendAdaptationToVisualization

      private void sendAdaptationToVisualization()
      Sends the adaptation to the visualization/frontend via the websocket.
    • getObservedAdaptation

      public Adaptation getObservedAdaptation()
    • getWebsocket

      public VisualizationWebsocket getWebsocket()
    • getGp3Socket

      public GazepointSocket getGp3Socket()
    • getClassifierModel

      public PythonServerCore getClassifierModel()
    • getGazeWindow

      public GazeWindow getGazeWindow()
    • setWebsocket

      public void setWebsocket(VisualizationWebsocket websocket)
    • setGp3Socket

      public void setGp3Socket(GazepointSocket gazepointSocket)
    • setClassifierModel

      public void setClassifierModel(PythonServerCore pythonServerCore)
    • setGazeWindow

      public void setGazeWindow(GazeWindow gazeWindow)