public void TestScoreStrictCloseToTarget() { _cpTaskEnv = CreateEnvironment(FitnessFunction.StrictCloseToTarget); _cpTaskEnv.ResetAll(); // All values are correct double[][] actions = Utilities.DeepCopy(_cpTaskEnv.Sequence); double score = CalcScore(actions); Assert.AreEqual(_cpTaskEnv.CurrentScore, _cpTaskEnv.MaxScore, "Max score assert"); // All values are wrong _cpTaskEnv.ResetAll(); actions = Utilities.DeepCopy(_cpTaskEnv.Sequence); for (int i = 0; i < actions.Length; i++) { for (int j = 0; j < actions[i].Length; j++) { if (actions[i][j] == 1) { actions[i][j] = 0; } else { actions[i][j] = 1; } } } Assert.AreEqual(_cpTaskEnv.CurrentScore, 0, "Min score assert"); }
public void TestScoreClosestBinary() { _cpTaskEnv = CreateEnvironment(FitnessFunction.ClosestBinary); _cpTaskEnv.ResetAll(); // All values are correct double[][] actions = new double[_cpTaskEnv.Sequence.Length][]; for (int i = 0; i < _cpTaskEnv.Sequence.Length; i++) { actions[i] = new double[_cpTaskEnv.Sequence[i].Length]; for (int j = 0; j < _cpTaskEnv.Sequence[i].Length; j++) { if (_cpTaskEnv.Sequence[i][j] == 1) { actions[i][j] = 0.6; } else { actions[i][j] = 0.4; } } } double score = CalcScore(actions); Assert.AreEqual(score, _cpTaskEnv.MaxScore, "Max score assert"); // All values are wrong _cpTaskEnv.ResetAll(); actions = new double[_cpTaskEnv.Sequence.Length][]; for (int i = 0; i < _cpTaskEnv.Sequence.Length; i++) { actions[i] = new double[_cpTaskEnv.Sequence[i].Length]; for (int j = 0; j < _cpTaskEnv.Sequence[i].Length; j++) { if (_cpTaskEnv.Sequence[i][j] == 1) { actions[i][j] = 0.4; } else { actions[i][j] = 0.6; } } } score = CalcScore(actions); Assert.AreEqual(score, 0, "Min score assert"); }
public void Before() { _cpTaskEnv = CreateEnvironment(FitnessFunction.StrictCloseToTarget); _cpTaskEnv.ResetAll(); }