public override FitnessTest CreateTest(ITestParameters parameters)
        {
            var singleTest = new IMRLTest((IFitnessScenario)this.Scenario.Clone(), parameters);

            singleTest.Reset();
            return(singleTest);
        }
        public override FitnessTest CreateTest(ITestParameters parameters)
        {
            var singleTest = new SocialGPFitnessTest(this.Scenario, (SocialGPChromosome)parameters);

            singleTest.Reset();
            return(singleTest);
        }
Beispiel #3
0
        public virtual FitnessTest CreateTest(ITestParameters parameters)
        {
            var singleTest = new FitnessTest(this.Scenario, parameters);

            singleTest.Reset();
            return(singleTest);
        }
        public override FitnessTest CreateTest(ITestParameters parameters)
        {
            var singleTest = new EmotionalTest((IFitnessScenario)this.Scenario.Clone(), (ArrayParameter)parameters);

            singleTest.Reset();
            return(singleTest);
        }
Beispiel #5
0
        protected override ITestParameters ComputeNeighbour(ITestParameters currentParam)
        {
            //first tested params
            if (currentParam == null)
            {
                return(this.testsConfig.SingleTestParameters);
            }

            //define search radius based on temperature
            var next = (ArrayParameter)currentParam.Clone();
            var initialTemperature = this.TestsConfig.InitialTemperature;
            var searchRadius       = 2 * Random.NextDouble() * (1d - ((initialTemperature - temperature) / initialTemperature));

            //generate random point in hyper-sphere according to radius
            for (var i = 0; i < next.Length; i++)
            {
                //"moves" current point in the direction of that point
                next[i] = ((ArrayParameter)currentParam)[i] + (searchRadius * ((Random.NextDouble() * 2) - 1d));
            }

            //normalizes result
            next.NormalizeUnitSum();
            next.Round();

            return(next);
        }
Beispiel #6
0
 public virtual bool Equals(ITestParameters other)
 {
     if (!(other is ArrayParameter))
     {
         return(false);
     }
     return(this.Equals((ArrayParameter)other));
 }
Beispiel #7
0
        public override FitnessTest CreateTest(ITestParameters parameters)
        {
            //gets parameters
            var test = new AltruismTest(this.Scenario, (ISocialTestParameters)parameters);

            test.Reset();
            return(test);
        }
 public IMRLTest(IFitnessScenario scenario, ITestParameters testParameters)
     : base(scenario, testParameters)
 {
     if (testParameters is ArrayParameter arrayParameters)
     {
         arrayParameters.Header = this.TestsConfig.ParamIDNames;
     }
 }
        protected virtual void RunSingleTest(ITestParameters parameters)
        {
            var test = this.OptimizationTestFactory.CreateTest(parameters);

            this.PrepareSingleTest(test);
            test.Run();
            this.FinishSingleTest(test);
        }
Beispiel #10
0
 public bool Equals(ITestParameters other)
 {
     if (!(other is SocialArrayParameter))
     {
         return(false);
     }
     return(this.Equals((SocialArrayParameter)other));
 }
Beispiel #11
0
        private static ITestsConfig CreateNewTestsConfig(
            ITestsConfig baseTestsConfig, uint testType, ITestParameters testParameters)
        {
            var testsConfig = baseTestsConfig.CloneJson();

            testsConfig.Init();
            testsConfig.SingleTestType       = testType;
            testsConfig.SingleTestParameters = testParameters;
            return(testsConfig);
        }
Beispiel #12
0
        public bool Equals(ITestParameters other)
        {
            if (!(other is SocialCommonTestParameters))
            {
                return(false);
            }
            var otherSocialParams = (SocialCommonTestParameters)other;

            return(otherSocialParams.NumAgents.Equals(this.NumAgents) &&
                   otherSocialParams.CommonTestParameters.Equals(this.CommonTestParameters));
        }
        protected string GetTranslatedExpression(IScenario scenario, ITestParameters testParameters)
        {
            var agent = new EchoGPSocialAgent
            {
                TestParameters = testParameters,
                Scenario       = (IFoodSharingScenario)scenario,
                Environment    = new FoodSharingEnvironment()
            };

            agent.Init();
            return(agent.MotivationManager.TranslatedExpression);
        }
        protected SingleTest(IScenario scenario, ITestParameters testParameters)
        {
            //checks arguments
            if (scenario == null)
            {
                throw new ArgumentNullException(nameof(scenario), @"testProfile can't be null");
            }

            this.TestParameters = testParameters;
            this.Scenario       = scenario;
            this.TestName       = scenario.TestsConfig.GetTestName(scenario, testParameters);
        }
 protected virtual List <string> GetOptions(ITestParameters singleTestParams)
 {
     return(new List <string>
     {
         GetSingleTestOption(singleTestParams),
         OPTIM_TEST_OPTION,
         MANUAL_SELECT_OPTION,
         CREATE_CONFIGS_OPTION,
         RANK_TEST_OPTION,
         CREATE_CONDOR_OPTION
     });
 }
        public override string GetTestName(IScenario scenario, ITestParameters testParameters)
        {
            //create test name from parameters, eg (a-0.1_b0.7_c0.2)
            var paramLetterIDs = this.ParamIDLetters;
            var arrayParameter = (ArrayParameter)testParameters;
            var sb             = new StringBuilder("(");

            for (var i = 0; i < arrayParameter.Length; i++)
            {
                sb.AppendFormat("{0}{1:0.0}_", paramLetterIDs[i], arrayParameter[i]);
            }

            sb.Remove(sb.Length - 1, 1);
            sb.Append(")");
            return(sb.ToString());
        }
        public override string GetTestName(IScenario scenario, ITestParameters testParameters)
        {
            //gets test name from translated expression
            if (this.SameAgentParameters)
            {
                return(this.GetTranslatedExpression(scenario, testParameters));
            }

            var translatedExpr = "";

            for (var i = 0u; i < ((ISocialScenario)scenario).NumAgents; i++)
            {
                translatedExpr = string.Format("{0}{1};", translatedExpr,
                                               this.GetTranslatedExpression(scenario, ((ISocialTestParameters)testParameters)[i]));
            }
            return(translatedExpr);
        }
        protected virtual double ComputeFitness(ITestParameters testParameters)
        {
            //checks whether test has been already executed, updating information
            if (!this.testMeasures.Contains(testParameters))
            {
                //create new test with given test params
                var test = this.optimizationTestFactory.CreateTest(testParameters);

                //runs test
                test.Run();

                //adds test results to measures list
                this.testMeasures.Add(testParameters, this.optimizationTestFactory.CreateTestMeasure(test));
            }

            //returns test results
            return(this.testMeasures.GetTestMeasure(testParameters).Value);
        }
        protected double ComputeBestNeighbour(ITestParameters current, out ITestParameters bestNeighbour)
        {
            bestNeighbour = null;
            var bestNeighbourValue = double.MinValue;

            for (var i = 0; i < this.TestsConfig.NumTestsPerIteration; i++)
            {
                var neighbour      = this.ComputeNeighbour(current);
                var neighbourValue = this.ComputeFitness(neighbour);

                if (!(neighbourValue > bestNeighbourValue))
                {
                    continue;
                }
                bestNeighbourValue = neighbourValue;
                bestNeighbour      = neighbour;
            }
            return(bestNeighbourValue);
        }
Beispiel #20
0
        public override string GetTestName(IScenario scenario, ITestParameters testParameters)
        {
            //create test name from parameters, eg (a-0.1_b0.7_c0.2)
            var paramLetterIDs = this.ParamIDLetters;

            var socialTestProfile = (ISocialScenario)scenario;
            var sb = new StringBuilder("(");

            for (var agIdx = 0u; agIdx < socialTestProfile.NumAgents; agIdx++)
            {
                var arrayParameter = ((SocialArrayParameter)testParameters)[agIdx];
                for (var i = 0; i < arrayParameter.Length; i++)
                {
                    sb.AppendFormat("{0}{1}{2:0.0}_", paramLetterIDs[i], agIdx, arrayParameter[i]);
                }
            }

            sb.Remove(sb.Length - 1, 1);
            sb.Append(")");
            return(sb.ToString());
        }
        protected override void RunIteration()
        {
            this.IterationNumber = 0;
            ITestParameters currentParam = null, bestParam = null;

            this.temperature = this.TestsConfig.InitialTemperature;
            this.MaxFitness  = double.MinValue;

            //while the temperature did not reach threshold
            while (!this.Terminated && (this.temperature > this.TestsConfig.TempThreshold))
            {
                this.IterationNumber++;

                //get the next random permutation of values and compute the best
                ITestParameters bestNeighbour;
                var             bestNeighbourValue = this.ComputeBestNeighbour(currentParam, out bestNeighbour);

                if (bestNeighbourValue > this.MaxFitness)
                {
                    //accept and assign the new args if the value is max
                    this.MaxFitness = bestNeighbourValue;
                    bestParam       = currentParam = bestNeighbour;
                }
                else if (Random.NextDouble() < this.ChangeProbability(bestNeighbourValue))
                {
                    //if the new value is worse accept it but with a probability level
                    //less than E to the power -delta/temperature.
                    currentParam = bestNeighbour;
                }
                else
                {
                    currentParam = bestParam;
                }

                //cooling process on every iteration
                temperature *= this.TestsConfig.Alpha;
            }
        }
 public override string GetTestName(IScenario scenario, ITestParameters testParameters)
 {
     return(Util.GetTranslatedExpression(testParameters.ToString(),
                                         this.Constants, ForagingGPMotivationManager.VariableNames));
 }
 protected SequentialTest(SingleScenario scenario, ITestParameters testParameters)
     : base(scenario, testParameters)
 {
 }
Beispiel #24
0
 protected ParallelTest(IScenario scenario, ITestParameters testParameters)
     : base(scenario, testParameters)
 {
 }
 protected abstract ITestParameters ComputeNeighbour(ITestParameters currentParam);
Beispiel #26
0
 public FitnessTest(IFitnessScenario scenario, ITestParameters testParameters)
     : base(scenario, testParameters)
 {
 }
Beispiel #27
0
 public EmotionalTest(IFitnessScenario scenario, ITestParameters testParameters)
     : base(scenario, testParameters)
 {
 }
 private static string GetSingleTestOption(ITestParameters singleTestParams)
 {
     return(string.Format("{0} ({1})", SINGLE_TEST_OPTION, singleTestParams.ToScreenString()));
 }
 public override string GetTestName(IScenario scenario, ITestParameters testParameters)
 {
     return(testParameters.ToString());
 }
Beispiel #30
0
 public bool Equals(ITestParameters other)
 {
     return((other is ECChromosome) &&
            this.ToString().Equals(other.ToString()));
 }