コード例 #1
0
        private void RunUnitLoop(HH hh, List <Person> tu)
        {
            // store the "running" variables (yem_unit, ils_earns_unit), and take the level into account
            foreach (StoreVar v in vars)
            {
                if (v.iteration != NOTAP)
                {
                    continue;                       // is handled below
                }
                if (hh.GetPersonValue(varIndexCurElig, tu[0].indexInHH) <= 0)
                {
                    continue;                                                         // store only for the (head of the) "currently elig" unit
                }
                List <Person> altTU  = hh.GetAlternativeTU(v.level, tu, description); // on may consider performance here, but let's first get it right
                double        levVal = v.unitLoopILPar == null?hh.GetTUValue(v.origVar.index, altTU) : v.unitLoopILPar.GetValue(hh, altTU);

                hh.SetPersonValue(levVal, v.storeVar.index, tu[0].indexInHH);
            }

            // store the "on demand" variables (e.g. yem_unit1) - they are stored the same way as for a normal loops (i.e. no level-stuff)
            foreach (StoreVar v in vars)
            {
                if (v.iteration != NOTAP && v.iteration == hh.GetPersonValue(varIndexLoopCounter, 0))
                {
                    hh.SetTUValue(hh.GetTUValue(v.origVar.index, tu), v.storeVar.index, tu);
                }
            }
        }
コード例 #2
0
        internal double GetValueTarget(HH hh, List <Person> tu, Person person = null)
        {
            double val;

            if (isTULevel)
            {
                val = hh.GetTUValue(index, tu);
            }
            else
            {
                if (person == null || target == DefPar.PREFIX.HEAD)
                {
                    val = hh.GetPersonValue(index, tu[0].indexInHH);
                }
                else if (target == DefPar.PREFIX.PARTNER)
                {
                    if (tu[0].partnerIndexInHH == byte.MaxValue)    // "no partner found! issue error" This is NOT the case in the old executable... for now, just give the Head value instead
                    {
                        //                        infoStore.communicator.ReportError(new Communicator.ErrorInfo()
                        //                        { isWarning = false, message = $"{description.Get()}: no partner found in assessment unit" });
                        val = double.NaN;
                    }
                    else
                    {
                        val = hh.GetPersonValue(index, tu[0].partnerIndexInHH);
                    }
                }
                else
                {
                    val = hh.GetPersonValue(index, person.indexInHH);
                }
            }
            return(val);
        }
コード例 #3
0
 private void SetCurElig(HH hh, double curIter)
 {
     foreach (List <Person> tu in hh.GetTUs(eligUnit))                // set the variable for each TU in the HH
     {
         double eligInIter = hh.GetTUValue(varIndexIsEligInIter, tu); // assess in which iteration the TU is "elig"
         hh.SetTUValue(eligInIter == curIter ? 1 : 0, varIndexIsCurElig, tu);
     }
 }
コード例 #4
0
        internal override void Run(HH hh, List <Person> tu) // note: Scale does not have a TAX_UNIT parameter
        {                                                   // therefore tu is DUMMY_INDIVIDUAL_TU, i.e. this is called for each person
            if (factorVar == 1 || !IsRunCondMet(hh))
            {
                return;
            }

            foreach (int varIndex in infoStore.operandAdmin.GetMonetaryVarIndices())
            {
                hh.SetTUValue(hh.GetTUValue(varIndex, tu) * factorVar, varIndex, tu);
            }
        }
コード例 #5
0
        private void RunLoopAndFix(HH hh, List <Person> tu)
        {
            // remark: gets an "invalid" loop-counter (0/end of loop) if a loop-store is used outside a loop, but that's a developer error/decision
            double curIteration = varIndexLoopCounter == NOTAP ? NOTAP : hh.GetPersonValue(varIndexLoopCounter, 0);

            foreach (StoreVar v in vars)
            {
                if (v.iteration == NOTAP ||      // always stored (possibly overwritten): yem_loop, yem_backup, i.e. in each iteration or outside any loop
                    v.iteration == curIteration) // stored only if it is the appropriate iteration: yem_loop7
                {
                    hh.SetTUValue(hh.GetTUValue(v.origVar.index, tu), v.storeVar.index, tu);
                }
            }
        }
コード例 #6
0
        // note that Restore actually does not have a TAX_UNIT, thus this is the HHAdmin.DUMMY_INDIVIDUAL_TU (see FunInSpineBase.GetTUName)
        // that means, amongst others, that the function is called for each person in the household (i.e. tu always contains one person)
        internal override void Run(HH hh, List <Person> tu)
        {
            if (!IsRunCondMet(hh))
            {
                return;
            }

            foreach (FunStore.StoreVar v in relatedStore.vars)
            {
                if (loopIteration == -1 || v.iteration == loopIteration)
                {
                    hh.SetTUValue(hh.GetTUValue(v.storeVar.index, tu), v.origVar.index, tu);
                }
            }
        }
コード例 #7
0
        // person != null: value is requested for a specific person
        // person == null: monetary: value is requested for tu, non-monetary: value is taken from head
        internal override double GetValue(HH hh, List <Person> tu, Person person = null)
        {
            if (alternativeTU != null)
            {
                tu = hh.GetAlternativeTU(alternativeTU, tu, description);
            }
            double val;

            if (target == DefPar.PREFIX.NONE)
            {
                val = person == null && isTULevel?hh.GetTUValue(index, tu)
                          : hh.GetPersonValue(index, person == null ? tu[0].indexInHH
                                                                                            : person.indexInHH);
            }
            else
            {
                val = GetValueTarget(hh, tu, person);
            }
            return(ApplyLimits(val, hh, tu, person));
        }
コード例 #8
0
        private double getComponentValue(HH hh, List <Person> tu, Person person, List <Entry> component)
        {
            double value = 0;

            foreach (Entry entry in component)
            {
                double eVal;
                if (entry.isIL)
                {
                    eVal = getComponentValue(hh, tu, person, entry.ilEntries);
                }
                else
                {
                    eVal = person == null?hh.GetTUValue(entry.varSpec.index, tu)
                               : hh.GetPersonValue(entry.varSpec.index, person.indexInHH);
                }
                value += entry.addFactor * eVal;
            }
            return(value);
        }