Пример #1
0
        public OptimizationState(Tuple <double, double> objectiveMaxValues, List <Tuple <double, double> > optimalParetoFront)
        {
            this.objectiveMaxValues = objectiveMaxValues;
            this.optimalParetoFront = optimalParetoFront;
            dominationComparer      = new DefaultDominationComparer();

            SetNewResult();
        }
Пример #2
0
        private static void Lab8BiObjectiveBinaryGA(IEvaluation <bool, Tuple <double, double> > evaluation, int?seed)
        {
            RunningTimeStopCondition stopCondition = new RunningTimeStopCondition(5);

            DefaultDominationComparer dominationComparer = new DefaultDominationComparer();

            BinaryRandomGenerator      generator = new BinaryRandomGenerator(evaluation.pcConstraint, seed);
            OnePointCrossover          crossover = new OnePointCrossover(0.5, seed);
            BinaryBitFlipMutation      mutation  = new BinaryBitFlipMutation(1.0 / evaluation.iSize, evaluation, seed);
            SampleBiObjectiveSelection selection = new SampleBiObjectiveSelection(dominationComparer, seed);

            BiObjective.GeneticAlgorithm <bool> ga = new BiObjective.GeneticAlgorithm <bool>(evaluation, stopCondition, generator, selection, crossover, mutation, 100, seed);

            ga.Run();

            ReportBiObjectiveOptimizationResult(ga.Result);
        }
Пример #3
0
        private static Experiment <bool, Tuple <double, double>, BiObjective.OptimizationResult <bool> > PrepareExperiment9(int method, int evaluationType, int selectionMethod, double mutationProb, int populationSize, int?seed = null)
        {
            IEvaluation <bool, Tuple <double, double> > evaluation;
            Dictionary <string, string> info = new Dictionary <string, string>();
            DefaultDominationComparer   dominationComparer = new DefaultDominationComparer();

            switch (evaluationType)
            {
            case 0:
                evaluation      = new CBinaryZeroMaxOneMaxEvaluation(100);
                info["problem"] = "ZeroMaxOneMax";
                break;

            case 1:
                evaluation      = new CBinaryTrapInvTrapEvaluation(5, 100);
                info["problem"] = "Trap5InvTrap5";
                break;

            case 2:
                evaluation      = new CBinaryLOTZEvaluation(10);
                info["problem"] = "LOTZ";
                break;

            case 3:
                evaluation      = new CBinaryMOMaxCutEvaluation(EBinaryBiObjectiveMaxCutInstance.maxcut_instance_100);
                info["problem"] = "MaxCut";
                break;

            case 4:
                evaluation      = new CBinaryMOKnapsackEvaluation(EBinaryBiObjectiveKnapsackInstance.knapsack_100);
                info["problem"] = "MOKnapsack";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            info["variables"] = evaluation.iSize.ToString();
            RunningTimeStopCondition             stopCondition = new RunningTimeStopCondition(30);
            BinaryRandomGenerator                generator     = new BinaryRandomGenerator(evaluation.pcConstraint, seed);
            OnePointCrossover                    crossover     = new OnePointCrossover(0.5, seed);
            BinaryBitFlipMutation                mutation      = new BinaryBitFlipMutation(1.0 / evaluation.iSize, evaluation, seed);
            ASelection <Tuple <double, double> > selection;

            switch (selectionMethod)
            {
            case 0:
                selection = new SampleBiObjectiveSelection(dominationComparer, seed);
                info["selection_method"] = "Sample";
                break;

            case 1:
                selection = new NSGA2Selection(10, evaluation.tMaxValue, dominationComparer, true, seed);
                info["selection_method"] = "NSGA2";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            mutationProb          = mutationProb / evaluation.iSize;
            info["mutation_prob"] = mutationProb.ToString();
            info["population"]    = populationSize.ToString();
            BiObjective.GeneticAlgorithm <bool> ga;
            switch (method)
            {
            case 0:
                ga             = new BiObjective.GeneticAlgorithm <bool>(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize, seed);
                info["method"] = "GA";
                break;

            case 1:
                ga             = new BiObjective.ClusteringGeneticAlgorithm <bool>(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize, populationSize / 10, seed);
                info["method"] = "ClusteringGA";
                break;

            case 2:
                ga             = new BiObjective.ClusteringGeneticAlgorithm2 <bool>(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize, populationSize / 10, seed);
                info["method"] = "ClusteringGA2";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            Experiment <bool, Tuple <double, double>, BiObjective.OptimizationResult <bool> > experiment = new Experiment <bool, Tuple <double, double>, BiObjective.OptimizationResult <bool> >(ga, info, ExperimentFinished);

            return(experiment);
        }