public void Run(Clock clock, IGlobalWelfareState state, IDimensions dimensions)
        {
            var s = state;
            var t = clock.Current;

            if (clock.IsFirstTimestep)
            {
                s.cummulativewelfare[t] = 0;
            }
            else
            {
                if (t >= s.starttimestep)
                {
                    var U = Funcifier.Funcify(
                        (double consumption) =>
                    {
                        if (s.elasticityofmarginalutility == 1.0)
                        {
                            return(s.utilitycalibrationadditive + s.utilitycalibrationmultiplicative * Math.Log(consumption));
                        }
                        else
                        {
                            return(s.utilitycalibrationadditive + s.utilitycalibrationmultiplicative * Math.Pow(consumption, 1.0 - s.elasticityofmarginalutility) / (1.0 - s.elasticityofmarginalutility));
                        }
                    }
                        );

                    var DF = Funcifier.Funcify(
                        (Timestep year) =>
                    {
                        return(Math.Pow(1.0 + s.prtp, -(year.Value - s.starttimestep.Value)));
                    }
                        );

                    var perCapitaConsumption = s.consumption[t] / s.population[t];

                    if (perCapitaConsumption <= 0.0)
                    {
                        perCapitaConsumption = 1.0;
                    }

                    s.cummulativewelfare[t] = s.cummulativewelfare[t - 1] + (U(perCapitaConsumption) * s.population[t] * DF(t));
                    s.marginalwelfare[t]    = DF(t) * s.utilitycalibrationmultiplicative / Math.Pow(perCapitaConsumption, s.elasticityofmarginalutility);

                    if (t == s.stoptimestep)
                    {
                        s.totalwelfare = s.cummulativewelfare[t];
                    }
                }
                else
                {
                    s.cummulativewelfare[t] = 0;
                }
            }
        }
Beispiel #2
0
        public void Run(Clock clock, IGlobalWelfareState state, IDimensions dimensions)
        {
            var s = state;
            var t = clock.Current;

            if (clock.IsFirstTimestep)
            {
                s.cummulativewelfare[t] = 0;
            }
            else
            {
                if (t >= s.starttimestep)
                {

                    var U = Funcifier.Funcify(
                        (double consumption) =>
                        {
                            if (s.elasticityofmarginalutility == 1.0)
                                return s.utilitycalibrationadditive + s.utilitycalibrationmultiplicative * Math.Log(consumption);
                            else
                                return s.utilitycalibrationadditive + s.utilitycalibrationmultiplicative * Math.Pow(consumption, 1.0 - s.elasticityofmarginalutility) / (1.0 - s.elasticityofmarginalutility);
                        }
                        );

                    var DF = Funcifier.Funcify(
                        (Timestep year) =>
                        {
                            return Math.Pow(1.0 + s.prtp, -(year.Value - s.starttimestep.Value));
                        }
                        );

                    var perCapitaConsumption = s.consumption[t] / s.population[t];

                    if (perCapitaConsumption <= 0.0)
                        perCapitaConsumption = 1.0;

                    s.cummulativewelfare[t] = s.cummulativewelfare[t - 1] + (U(perCapitaConsumption) * s.population[t] * DF(t));
                    s.marginalwelfare[t] = DF(t) * s.utilitycalibrationmultiplicative / Math.Pow(perCapitaConsumption, s.elasticityofmarginalutility);

                    if (t == s.stoptimestep)
                    {
                        s.totalwelfare = s.cummulativewelfare[t];
                    }
                }
                else
                    s.cummulativewelfare[t] = 0;
            }
        }