Package adaptlil.mediator
Class AdaptationMediator
java.lang.Object
adaptlil.mediator.Mediator
adaptlil.mediator.AdaptationMediator
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 Summary
Modifier and TypeFieldDescription(package private) Map<String,
Adaptation> private int
private double
private GazepointSocket
private GazeWindow
private double
private boolean
private int
private int
private Adaptation
private PythonServerCore
private double
private double
private VisualizationWebsocket
-
Constructor Summary
ConstructorDescriptionAdaptationMediator
(VisualizationWebsocket websocket, GazepointSocket gazepointSocket, PythonServerCore pythonServerCore, GazeWindow gazeWindow, int numSequencesForClassification) -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
void
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.private int
countTaskFailureClassifications
(int[] classifications) Counts Number of task success ocurrences (i.e.private void
countTaskFailurePredictionsAndInvokeAdaptation
(int[] classifications) Counts # task failure predictions and runs through the rule-based adaptation selectionorg.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.private Adaptation
Get a new adaptation typeprivate boolean
void
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)Returns the list of possible adaptation types.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.private void
Sends the adaptation to the visualization/frontend via the websocket.void
setClassifierModel
(PythonServerCore pythonServerCore) void
setGazeWindow
(GazeWindow gazeWindow) void
setGp3Socket
(GazepointSocket gazepointSocket) void
setWebsocket
(VisualizationWebsocket websocket) void
start()
Starts the entire adaptation mediator process.
-
Field Details
-
websocket
-
gazepointSocket
-
pythonServerCore
-
gazeWindow
-
isRunning
private boolean isRunning -
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
-
AdaptationMediator
public AdaptationMediator(VisualizationWebsocket websocket, GazepointSocket gazepointSocket, PythonServerCore pythonServerCore, GazeWindow gazeWindow, int numSequencesForClassification)
-
-
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
Get a new adaptation type- Returns:
-
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
-
getWebsocket
-
getGp3Socket
-
getClassifierModel
-
getGazeWindow
-
setWebsocket
-
setGp3Socket
-
setClassifierModel
-
setGazeWindow
-