Esempio n. 1
0
        // methodId - integer from 1 - 4
        // 1 - constant probability
        // 2 - variable probability
        // 3 - lotteries comparison
        // 4 - probability comparison
        public DialogController(PartialUtility partialUtility, int methodId, double p = 0.5)
        {
            _methodId                = methodId;
            DisplayObject            = new DisplayObject();
            PointsList               = partialUtility.PointsValues;
            DisplayObject.PointsList = PointsList;
            DisplayObject.P          = p;
            _zeroUtilityPoint        = partialUtility.PointsValues.Find(o => o.Y == 0);
            _oneUtilityPoint         = partialUtility.PointsValues.Find(o => o.Y == 1);

            if (_methodId == 1)
            {
                createConstantProbabilityObject();
            }
            else if (_methodId == 2)
            {
                createVariableProbabilityObject();
            }
            else if (_methodId == 3)
            {
                createLotteriesComparisonObject();
            }
            else if (_methodId == 4)
            {
                createProbabilityComparisonObject();
            }
        }
Esempio n. 2
0
        private (int, List <PartialUtilityValues>, double[]) NextPartialUtility(Dictionary <double, double> doubles, Criterion criterion,
                                                                                int count)
        {
            var linearSegments = criterion.LinearSegments;
            var arrayOfValues  = new double[criterion.LinearSegments];
            List <PartialUtilityValues> list;
            double segmentValue = Math.Round(((criterion.MaxValue - criterion.MinValue) / linearSegments), 14), currentPoint, currentValue = 0;

            if (criterion.CriterionDirection == "Gain")
            {
                currentPoint = criterion.MinValue;
                var partialUtilityValues = new PartialUtilityValues(currentPoint, currentValue);
                list = new List <PartialUtilityValues> {
                    partialUtilityValues
                };
                for (var s = 0; s < linearSegments; s++)
                {
                    currentPoint     = s < linearSegments - 1 ? criterion.MinValue + (s + 1) * segmentValue : criterion.MaxValue;
                    arrayOfValues[s] = 0;
                    if (doubles.Keys.Contains(count))
                    {
                        currentValue    += doubles[count];
                        arrayOfValues[s] = doubles[count];
                    }

                    partialUtilityValues = new PartialUtilityValues(currentPoint, currentValue);
                    list.Add(partialUtilityValues);
                    count++;
                }
            }
            else
            {
                currentPoint = criterion.MaxValue;
                var partialUtilityValues = new PartialUtilityValues(currentPoint, currentValue);
                list = new List <PartialUtilityValues> {
                    partialUtilityValues
                };
                for (var s = 0; s < linearSegments; s++)
                {
                    currentPoint     = s < linearSegments - 1 ? criterion.MaxValue - (s + 1) * segmentValue : criterion.MinValue;
                    arrayOfValues[s] = 0;
                    if (doubles.Keys.Contains(count))
                    {
                        currentValue    += doubles[count];
                        arrayOfValues[s] = doubles[count];
                    }
                    partialUtilityValues = new PartialUtilityValues(currentPoint, currentValue);
                    list.Add(partialUtilityValues);
                    count++;
                }
            }

            return(count, list, arrayOfValues);
        }
Esempio n. 3
0
 public Lottery(PartialUtilityValues lowerUtilityValue, PartialUtilityValues upperUtilityValue)
 {
     LowerUtilityValue = lowerUtilityValue;
     UpperUtilityValue = upperUtilityValue;
 }