void RunNextTrial() { int currentFinalIndex = (currentInitialTargetId + 1) % targets.Length; if (currentInitialTargetId < targets.Length) { TrialMeasurements lastTrial = null; if (blockMeasurements.trialsData.Count > 0) { lastTrial = blockMeasurements.trialsData[blockMeasurements.trialsData.Count - 1]; } if (task == ExperimentTask.ReciprocalDragging) { currentTrial = new DragTestController(currentInitialTargetId, targets[currentInitialTargetId], targets[currentFinalIndex], this, cursor, lastTrial); } else { currentTrial = new TappingTrialController(currentInitialTargetId, targets[currentInitialTargetId], targets[currentFinalIndex], this, cursor, lastTrial); } currentTrial.StartTrial(); } else { FinishBlockOfTrials(); } }
public void Start() { //FilePath = "C:\\Users\\JKMT\\Desktop\\OptimizationShooting.txt"; leftRules = new List <EvaluationTreeRuleBase>(PopulationSize); rightRules = new List <EvaluationTreeRuleBase>(PopulationSize); for (int i = 0; i < PopulationSize; i++) { leftRules.Add(FuzzyShootingUtil.CreateRandomEvaluationTreeRuleBase()); rightRules.Add(FuzzyShootingUtil.CreateRandomEvaluationTreeRuleBase()); } IsTrialRunning = false; TrialCount = 0; GenerationCount = 1; TrialController = Trial.GetComponent <TrialController>(); OrganismFactory = new EvaluationTreeRuleBaseFactory(FuzzyShootingUtil.InputSets, FuzzyShootingUtil.TorqueSet); GeneCopier = new RuleCopier(); SelectionMethod = new StochasticUniversalSamplingSelection(0.11f, 0.29f); CrossoverMethod = new UniformCrossover(); GeneticAlgorithm = new GeneticAlgorithm <EvaluationTreeRuleBase, Rule>(SelectionMethod, CrossoverMethod, OrganismFactory, GeneCopier); }
public void AbortBlock() { if (currentTrial != null) { currentTrial.AbortTrial(); } currentTrial = null; listener = null; }
/** * Parse trial details and pass them to the trial controller */ private void PrepareTrial(Dictionary <string, string> trial, TrialController trialController) { // Determine which hand to use for given gapsize if (trial["GapStatus"] == "Inactive") { trialController.hand = 0; } else if (trial["GapStatus"] == "Active") { trialController.hand = 1; } else { WriteLog("Invalid GapSize in protocol"); trialController.hand = -1; } WriteLog("Gap: " + trial["GapStatus"]); // Get Hand offset float offset; try { float.TryParse(trial["HandOffset"], out offset); trialController.offset = offset / 100.0f; } catch (Exception e) { throw new Exception("Could not parse HandOffset in ProtocolFile"); } WriteLog("HandOffset: " + offset); // Determine the number of waves per each trial int wavesRequired; int.TryParse(trial["WavesRequired"], out wavesRequired); trialController.wavesRequired = wavesRequired; // Determine noise type if (trial.ContainsKey("NoiseType")) { int.TryParse(trial["NoiseType"], out noiseType); WriteLog("Noise type " + noiseType); trialController.noiseType = noiseType; } // Noise level if (trial.ContainsKey("NoiseLevel")) { float noiseLevel; float.TryParse(trial["NoiseLevel"], out noiseLevel); trialController.noiseLevel = noiseLevel; WriteLog("NoiseLevel: " + noiseLevel); } else { trialController.noiseLevel = 0.0f; } if (trial.ContainsKey("NoiseLambda")) { float noiseLambda; float.TryParse(trial["NoiseLambda"], out noiseLambda); trialController.lNoise = noiseLambda; WriteLog("Lambda: " + noiseLambda); } else { trialController.lNoise = 0.0f; } // Determine collision probability if (trial.ContainsKey("CollisionProbability")) { float collisionProbability; float.TryParse(trial["CollisionProbability"], out collisionProbability); trialController.collisionProbability = collisionProbability; WriteLog("Collision probability: " + collisionProbability); } else { trialController.collisionProbability = 1.0f; } // Knife if (trial.ContainsKey("KnifePresent")) { if (trial["KnifePresent"].ToLower() == "true") { trialController.knifePresent = true; } else if (trial["KnifePresent"].ToLower() == "false") { trialController.knifePresent = false; } else { throw new Exception("Invalid value in trial list for field KnifePresent"); } WriteLog("Knife Present" + trialController.knifePresent); } else { trialController.knifePresent = false; } // Knife Offset if (trial.ContainsKey("KnifeOffset")) { float knifeOffsetx; float knifeOffsety; float knifeOffsetz; float.TryParse(trial["OffsetX"], out knifeOffsetx); float.TryParse(trial["OffsetY"], out knifeOffsety); float.TryParse(trial["OffsetZ"], out knifeOffsetz); Vector3 knifeVector = new Vector3(knifeOffsetx, knifeOffsety, knifeOffsetz); trialController.knifeOffset = knifeVector; WriteLog("Knife Offset: " + knifeVector); } // Temporal position of knife if (trial.ContainsKey("KnifeRandom")) { if (trial["KnifeRandom"].ToLower() == "false") { trialController.randomizeThreatWave = false; } else if (trial["KnifeRandom"].ToLower() == "true") { trialController.randomizeThreatWave = true; } else { throw new Exception("Invalid value in trial list for field KnifeRandom"); } WriteLog("Random Wave for Threat: " + trialController.randomizeThreatWave); } else { trialController.randomizeThreatWave = false; } if (trial.ContainsKey("KnifeOnReal")) { if (trial["KnifeOnReal"].ToLower() == "true") { trialController.knifeOnReal = true; } else if (trial["KnifeOnReal"].ToLower() == "false") { trialController.knifeOnReal = false; } } else { trialController.knifeOnReal = false; } // Gender Change if (trial.ContainsKey("ChangeGender")) { if (trial["ChangeGender"].ToLower() == "true") { trialController.changeGender = true; } else if (trial["ChangeGender"].ToLower() == "false") { trialController.changeGender = false; } } if (trial.ContainsKey("IgnoreUpdate")) { if (trial["IgnoreUpdate"].ToLower() == "false") { trialController.ignoreUpdate = false; } else if (trial["IgnoreUpdate"].ToLower() == "true") { trialController.ignoreUpdate = true; } else { throw new Exception("Invalid value for IgnoreUpdates"); } } switch (experimentType) { //case ExperimentType.ImplicitAgencyTest: // trialController.experimentType = ExperimentType.ImplicitAgencyTest; // break; //case ExperimentType.ImplicitOwnershipTest: // trialController.experimentType = ExperimentType.ImplicitOwnershipTest; // break; case ExperimentType.VisuomotorInformation: trialController.experimentType = ExperimentType.VisuomotorInformation; break; case ExperimentType.OutcomeOwnership: trialController.experimentType = ExperimentType.OutcomeOwnership; break; } }
private void Awake() { _instance = this; }