Ejemplo n.º 1
0
        private double fitnessCooperativeDefector(KnapsackList knapsackList)
        {
            Knapsack knapsack = knapsackList[0];
            double   sum      = 0.0;

            for (int i = 0; i < this.chromosome.Count; i++)
            {
                sum += this.chromosome[i] ? knapsack.GetValue(i) : 0.0;
            }

            if (this.isFeasible)
            {
                return(GA_GT.weightGA * sum / GA_GT.maxFitness
                       + GA_GT.weightGT * GA_GT.gameModel.cooperatorDefectorPayoff / GA_GT.maxPayoff);
            }

            else
            {
                return(GA_GT.weightGA * (sum - NonFeasibleKnapsacks(knapsackList) * knapsack.maxValue) / GA_GT.maxFitness
                       + GA_GT.weightGT * GA_GT.gameModel.cooperatorDefectorPayoff / GA_GT.maxPayoff);
            }
        }
Ejemplo n.º 2
0
        private double fitnessDefectorDefector(KnapsackList knapsackList)
        {
            Knapsack knapsack = knapsackList[0];
            double   deltaV   = GA_GT.cheatingDegree / 100.0;
            //double deltaW = GA_GT.cheatingDegree / 100.0;
            double sum = 0.0;

            for (int i = 0; i < this.chromosome.Count; i++)
            {
                sum += this.chromosome[i] ? knapsack.GetValue(i) + deltaV : 0.0;
            }

            if (this.isFeasible)
            {
                return(GA_GT.weightGA * sum / GA_GT.maxFitness
                       + GA_GT.weightGT * GA_GT.gameModel.defectorDefectorPayoff / GA_GT.maxPayoff);
            }

            else
            {
                return(GA_GT.weightGA * (sum - NonFeasibleKnapsacks(knapsackList) * knapsack.maxValue) / GA_GT.maxFitness
                       + GA_GT.weightGT * GA_GT.gameModel.defectorDefectorPayoff / GA_GT.maxPayoff);
            }
        }