static internal void ReplaceCountrySymbol(CountryConfig.FunctionRow functionRow, string countryShortName)
 {
     foreach (CountryConfig.ParameterRow parameterRow in functionRow.GetParameterRows())
     {
         ReplaceCountrySymbol(parameterRow, countryShortName);
     }
 }
示例#2
0
        void FillFunctionNodeWithParameters(CountryConfig.SystemRow systemRow, CountryConfig.FunctionRow functionRow, TreeListNode functionNode, bool isFirstSystem)
        {
            //generate the parameters of the function
            int parameterIndex = 0;
            var parameterQuery = (from parameter in functionRow.GetParameterRows() select parameter).OrderBy(parameter => long.Parse(parameter.Order));

            foreach (CountryConfig.ParameterRow parameterRow in parameterQuery.ToList())
            {
                TreeListNode parameterNode = isFirstSystem ? BuildParameterNode(functionNode, parameterRow) : functionNode.Nodes[parameterIndex++];
                (parameterNode.Tag as ParameterTreeListTag).AddParameterRowOfSystem(systemRow.ID, parameterRow);
                parameterNode.SetValue(systemRow.Name, parameterRow.Value);
            }
        }
        static CountryConfig.ParameterRow GetParameterRowByDisplayOrder(CountryConfigFacade countryConfigFacade, string functionID, string displayOrder)
        {
            try
            {
                CountryConfig.FunctionRow functionRow = countryConfigFacade.GetFunctionRowByID(functionID);
                int displayIndex = Convert.ToInt32(displayOrder) - 1;

                CountryConfig.ParameterRow par = null;
                if (functionRow != null && displayIndex >= 0)
                {
                    List <CountryConfig.ParameterRow> siblingParameters = functionRow.GetParameterRows().OrderBy(p => long.Parse(p.Order)).ToList();
                    if (displayIndex < siblingParameters.Count)
                    {
                        par = siblingParameters.ElementAt(displayIndex);
                    }
                }
                return(par);
            }
            catch { return(null); }
        }
        static internal string GetSymbolicID(CountryConfig.FunctionRow functionRow, string replaceCountryShortName = "")
        {
            //for functions DefIL and DefTU use a more practical and less insecure identifier than display order, i.e. the name
            if (functionRow.Name.ToLower() == DefFun.DefIl.ToLower() || functionRow.Name.ToLower() == DefFun.DefTu.ToLower())
            {
                foreach (CountryConfig.ParameterRow parameterRow in functionRow.GetParameterRows())
                {
                    if (parameterRow.Name.ToLower() == DefPar.DefIl.Name.ToLower())
                    {
                        string symbolicID = parameterRow.Value; //replace country symbol in taxunit name if required (e.g. tu_individual_sl -> tu_individua_=cc=)
                        if (replaceCountryShortName != string.Empty && functionRow.Name.ToLower() == DefFun.DefTu.ToLower() && symbolicID.ToLower().EndsWith(replaceCountryShortName.ToLower()))
                        {
                            symbolicID = symbolicID.Substring(0, symbolicID.Length - replaceCountryShortName.Length) + DefPar.Value.PLACEHOLDER_CC;
                        }
                        return(GetSymbolicID(functionRow.PolicyRow, replaceCountryShortName) + _symbolicID_OrderSeparator + symbolicID); //e.g. ILDef_sl_#ils_dispy for the function defining ils_dispy in policy ILDef_sl
                    }
                } //should not happen, but if no name-parameter found still use order
            }

            //for all other functions use display order
            return(GetSymbolicID(functionRow.PolicyRow, replaceCountryShortName) + _symbolicID_OrderSeparator + OrderToDisplayOrder(functionRow)); //e.g. ILDef_sl_#10 for the 10th function in policy ILDef_sl
        }
        private int GetMaxGroupUsedByFunction(CountryConfig.FunctionRow functionRow, string groupName)
        {
            int maxGroup = 0; List <string> potentialGroupPars = new List <string>();

            DefinitionAdmin.Fun fun = DefinitionAdmin.GetFunDefinition(functionRow.Name, false);
            if (fun != null)         // find all parameters belonging to this group, e.g. functionRow.Name=BenCalc, groupName=Comp_X:
            {                        // find: Comp_PerTU, Comp_PerElig, Comp_Cond, Comp_LowLim, Comp_UpLim
                var pgs = from pg in fun.GetGroupParList() where pg.groupName.ToLower() == groupName.ToLower() select pg;
                if (pgs.Count() > 0) // this should always be fulfilled (i.e. the function has such a group)
                {
                    foreach (var p in pgs.First().par)
                    {
                        potentialGroupPars.Add(p.Key.ToLower());
                        foreach (string s in p.Value.substitutes)
                        {
                            potentialGroupPars.Add(s);
                        }
                    }
                }
            }
            foreach (CountryConfig.ParameterRow countryConfigParameterRow in functionRow.GetParameterRows())
            {
                if (countryConfigParameterRow.Group == string.Empty || !EM_Helpers.IsNonNegInteger(countryConfigParameterRow.Group))
                {
                    continue; //no group parameter
                }
                if (!potentialGroupPars.Contains(countryConfigParameterRow.Name.ToLower()) && !IsPlaceholderSibling(countryConfigParameterRow, potentialGroupPars))
                {
                    continue; //no sibling
                }
                if (EM_Helpers.SaveConvertToInt(countryConfigParameterRow.Group) > maxGroup)
                {
                    maxGroup = EM_Helpers.SaveConvertToInt(countryConfigParameterRow.Group);
                }
            }
            return(maxGroup);
        }
        void AddParameters()
        {
            //analyse all AddOn_Par functions
            foreach (CountryConfig.FunctionRow function_AddOnParameters in
                     _addOnCountryConfigFacade.GetFunctionRowsBySystemIDAndFunctionName(_addOnSystemRow.ID, DefFun.AddOn_Par))
            {
                if (function_AddOnParameters.Switch.ToLower() != DefPar.Value.ON.ToLower())
                {
                    continue;
                }

                //assess which parameters are to be merged and into which function by interpreting the AddOnPar-function's parameters
                CountryConfig.ParameterRow parameter_InsertFunctionID = _addOnCountryConfigFacade.GetParameterRowByName(function_AddOnParameters.ID, DefPar.AddOn_Par.Insert_Func);
                if (parameter_InsertFunctionID == null)
                {
                    _errorMessages += ImportExportHelper.GenerateErrorMessage(function_AddOnParameters, "Compulsory parameter '" + DefPar.AddOn_Par.Insert_Func + "' not defined.");
                    continue;
                }

                //search for the function where parameters are to be added in the just generated (copied) system
                CountryConfig.FunctionRow addOnParameters_InsertFunction = _mergeCountryConfigFacade.GetFunctionRowByID(parameter_InsertFunctionID.Value);
                if (addOnParameters_InsertFunction == null) //take account of 'symbolic' identifier, e.g. output_std_sl_#3
                {
                    addOnParameters_InsertFunction = ImportExportHelper.GetFunctionRowBySymbolicID(parameter_InsertFunctionID.Value, _mergeCountryConfigFacade, _mergeSystemRow.ID);
                }

                if (addOnParameters_InsertFunction == null)
                {
                    _errorMessages += ImportExportHelper.GenerateErrorMessage(function_AddOnParameters, "Unknown function '" + parameter_InsertFunctionID.Value + "'.");
                    continue;
                }

                //if everything is ok, insert the parameters (all other parameters than insert_func in AddOn_Par) into the function
                foreach (CountryConfig.ParameterRow addOnParameters_ParameterNameAndValue in function_AddOnParameters.GetParameterRows())
                {
                    if (addOnParameters_ParameterNameAndValue.Name.ToLower() == DefPar.AddOn_Par.Insert_Func.ToLower())
                    {
                        continue;
                    }

                    DefinitionAdmin.Par parDef = DefinitionAdmin.GetParDefinition(addOnParameters_InsertFunction.Name, addOnParameters_ParameterNameAndValue.Name, false);
                    if (parDef == null)
                    {
                        _errorMessages += ImportExportHelper.GenerateErrorMessage(function_AddOnParameters,
                                                                                  "Function '" + addOnParameters_InsertFunction.Name + "' does not allow for parameter '" + addOnParameters_ParameterNameAndValue.Name + "'.");
                        continue;
                    }

                    //add parameter, however if a respective parameter with value n/a exists, it can be used
                    //this is even necessary for single parameters (which may only exist once) if an add-on is added more than once (i.e. there is already the n/a parameter of the first adding-on)
                    CountryConfig.ParameterRow        parameterRow  = null;
                    List <CountryConfig.ParameterRow> parameterList = (from pR in addOnParameters_InsertFunction.GetParameterRows()
                                                                       where pR.Name.ToLower() == addOnParameters_ParameterNameAndValue.Name.ToLower() &&
                                                                       pR.Group == addOnParameters_ParameterNameAndValue.Group &&
                                                                       pR.Value == DefPar.Value.NA
                                                                       select pR).ToList();
                    if (parameterList.Count != 0)
                    {
                        parameterRow = parameterList.First();
                    }

                    if (parameterRow == null)
                    {
                        parameterRow = CountryConfigFacade.AddParameterRowAtTail(addOnParameters_InsertFunction, addOnParameters_ParameterNameAndValue.Name, parDef);
                    }
                    if (parameterRow.Name.ToLower() == DefinitionAdmin.ParTypeToString(DefPar.PAR_TYPE.PLACEHOLDER).ToLower())
                    {
                        parameterRow.Name = addOnParameters_ParameterNameAndValue.Name; //for adding parameters e.g. to function DefIL
                    }
                    parameterRow.Value   = addOnParameters_ParameterNameAndValue.Value;
                    parameterRow.Comment = addOnParameters_ParameterNameAndValue.Comment;

                    ImportExportHelper.ReplaceCountrySymbol(parameterRow, _mergeCountryConfigFacade.GetCountryShortName()); //replace all incidents of =cc= by country symbol
                }
            }
        }
        internal void UpdateContent(TreeListNode focusedNode)
        {
            try
            {
                if (_inApplyAction)
                {
                    return;
                }

                _displayedFunctionRow = null;
                _focusedNode          = focusedNode; //needed to know where to put the parameters within the function

                if (_focusedNode != null && _focusedNode.Tag != null)
                {
                    _displayedFunctionRow = (_focusedNode.Tag as BaseTreeListTag).GetDefaultFunctionRow(); //selected function or function where selected parameter is part of (null if policy selelcted)
                }
                ClearContent();                                                                            //empty controls and activate/deactivate corresponding to whether a function is selected in the tree or not

                if (_displayedFunctionRow == null)
                {
                    return; //no function selected in tree
                }
                lblFunction.Text = _displayedFunctionRow.Name + " (order: " + _displayedFunctionRow.Order + ") in policy " + _displayedFunctionRow.PolicyRow.Name;

                Dictionary <string, string> groupList = new Dictionary <string, string>(); //helper list for group parameters

                foreach (AddParameterTag apt in GetFullParList(_displayedFunctionRow.Name))
                {
                    string parName = apt._parName; DefinitionAdmin.Par parDef = apt._parDef;
                    string groupName  = apt._parGroup == null ? string.Empty : apt._parGroup.groupName;
                    bool   isGroup    = apt._parGroup != null;        //parameter belongs/doesn't belong to a group; does: comp_Cond, comp_perTU
                    bool   isSingle   = parDef.maxCount == 1;         //parameter can/cannot be used more than once; can: DefOuput/Var, cannot: TAX_UNIT
                    bool   isFootnote = parDef.isFootnote;            //parameter is/isn't a footnote parameter; is: #_UpLim, #_Amount
                    bool   isConflict = parDef.substitutes.Count > 0; //parameter has/hasn't a Substitute; has: Output_Var / Output_Add_Var
                    bool   isIn       = false;                        //parameter isn't ...
                    foreach (CountryConfig.ParameterRow countryConfigParameterRow in _displayedFunctionRow.GetParameterRows())
                    {
                        if (countryConfigParameterRow.Name.ToLower() == parName.ToLower())
                        {
                            isIn = true; //.. is already used in the function
                            break;
                        }
                    }

                    string subsitude = string.Empty;
                    string groupOrNo = string.Empty;
                    string count     = string.Empty;

                    if (isSingle && !isGroup && !isFootnote && isIn)
                    {
                        continue; //parameter is already used (and multi use is not possible)
                    }
                    if (!isSingle || isGroup || isFootnote)
                    {
                        count = "1"; //as default multiple useable parameter is added once
                    }
                    if (isGroup)     //group parameter, e.g. comp_Cond, comp_perTU
                    {
                        //propse the likely group identifier, i.e. the next available number
                        if (groupList.Keys.Contains(groupName.ToLower()))
                        {
                            groupOrNo = groupList[groupName.ToLower()]; //for all group parameters of the same group the same group identifier is proposed
                        }
                        else
                        {
                            int maxGroup = GetMaxGroupUsedByFunction(_displayedFunctionRow, groupName) + 1;
                            groupOrNo = maxGroup.ToString();
                            groupList.Add(groupName.ToLower(), groupOrNo);
                        }
                    }

                    if (isFootnote) //footnote parameter, e.g. #_UpLim, #_Amount
                    {
                        //propse the likely footnote identifier, i.e. the next available number
                        groupOrNo = (CountryConfigFacade.GetMaxFootnoteUsedByFunction(_displayedFunctionRow, parName) + 1).ToString();
                    }

                    if (isConflict && !isGroup)
                    {//if e.g. output_var is already used, still show output_add_var, but put out_var in substitute column
                        TreeListNode functionNode = ((focusedNode.Tag as BaseTreeListTag).GetDefaultParameterRow() == null) ? focusedNode : focusedNode.ParentNode;

                        foreach (TreeListNode parameterNode in functionNode.Nodes)
                        {
                            string parameterName = parameterNode.GetDisplayText(TreeListBuilder._policyColumnName);
                            foreach (string conflictPar in parDef.substitutes)
                            {
                                if (parameterName.ToLower() == conflictPar.ToLower())
                                {
                                    subsitude          = parameterName;
                                    apt._parameterNode = parameterNode;
                                    break;
                                }
                            }
                            if (subsitude != string.Empty)
                            {
                                break;
                            }
                        }
                    }

                    int index = dgvParameter.Rows.Add(false, parName, subsitude, groupOrNo, count, parDef.description);
                    dgvParameter.Rows[index].Tag = apt;
                }

                ShowHideRows();
                dgvParameter.Select();
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowException(exception);
            }
        }
示例#8
0
        private void EM2_FixUprating(CountryConfig.SystemRow sr1, Dictionary <string, string> upratingFactors, Dictionary <string, string> upratingFactors2, string countryShortName, double alpha, int uprateType, bool treatAsMarket)
        {
            // first get the ils_origy & ils_ben components
            CountryConfig.PolicyRow ilsdef = sr1.GetPolicyRows().FirstOrDefault(p => p.Name.ToLower() == ("ilsdef_" + countryShortName).ToLower());
            if (ilsdef == null)
            {
                ilsdef = sr1.GetPolicyRows().FirstOrDefault(p => p.Name.ToLower() == ("ildef_" + countryShortName).ToLower());
            }
            if (ilsdef == null)
            {
                return;
            }

            CountryConfig.FunctionRow[] il_funcs = ilsdef.GetFunctionRows();
            List <string> ils_origy       = ExpandIncomeList(DefVarName.ILSORIGY, il_funcs).Keys.ToList();
            List <string> ils_ben         = ExpandIncomeList(DefVarName.ILSBEN, il_funcs).Keys.ToList();
            List <string> overrideInclude = ExpandIncomeList("pet_override", il_funcs).Where(x => x.Value).Select(x => x.Key).ToList();
            List <string> overrideExclude = ExpandIncomeList("pet_override", il_funcs).Where(x => !x.Value).Select(x => x.Key).ToList();

            List <string> reservedWords = new List <string> {
                "dataset", "def_factor", "factor_name", "factor_value", "factor_condition", "aggvar_name", "aggvar_part", "aggvar_tolerance", "warnifnofactor", "run_cond"
            };

            // Then apply them to the appropriate variables of s1
            foreach (CountryConfig.FunctionRow fr in sr1.GetPolicyRows().First(p => p.Name.ToLower() == ("Uprate_" + countryShortName).ToLower()).GetFunctionRows())
            {
                if (fr.Name.ToLower() == "uprate")
                {
                    foreach (CountryConfig.ParameterRow pr in fr.GetParameterRows())
                    {
                        string pn = pr.Name.ToLower();

                        if (!reservedWords.Contains(pn))
                        {
                            if (uprateType == 3)    // uprate all
                            {
                                double val;
                                if (upratingFactors.ContainsKey(pr.Value.ToLower()))
                                {
                                    pr.Value = FixDecSep((EM_Helpers.SaveConvertToDouble(upratingFactors2[pr.Value.ToLower()]) * alpha).ToString());
                                }
                                else if (EM_Helpers.TryConvertToDouble(pr.Value.ToLower(), out val))
                                {
                                    pr.Value = FixDecSep((val * alpha).ToString());
                                }
                            }
                            else
                            {
                                bool marketIncome = overrideInclude.Contains(pn);   // if in the override include list
                                if (!overrideExclude.Contains(pn) && !marketIncome) // else if not in the override exlcude list
                                {
                                    VarConfig.VariableRow v = EM_AppContext.Instance.GetVarConfigFacade().GetVariableByName(pn);
                                    if (v == null || v.Monetary != "1")
                                    {
                                        marketIncome = false;
                                    }
                                    else
                                    {
                                        if (treatAsMarket)
                                        {
                                            marketIncome = !pn.EndsWith(DefGeneral.POSTFIX_SIMULATED);
                                        }
                                        else
                                        {
                                            marketIncome = !ils_ben.Contains(pn) && (pn[0] == 'y' || pn[0] == 'a' || pn[0] == 'x' || ils_origy.Contains(pn));
                                        }
                                    }
                                }

                                // if this is a market income
                                if (marketIncome)
                                {
                                    if (uprateType == 1)
                                    {
                                        double val;
                                        if (upratingFactors.ContainsKey(pr.Value.ToLower()))
                                        {
                                            pr.Value = FixDecSep((EM_Helpers.SaveConvertToDouble(upratingFactors[pr.Value.ToLower()]) * alpha).ToString());
                                        }
                                        else if (EM_Helpers.TryConvertToDouble(pr.Value.ToLower(), out val))
                                        {
                                            pr.Value = FixDecSep((val * alpha).ToString());
                                        }
                                    }
                                    else if (uprateType == 2)
                                    {
                                        if (upratingFactors.ContainsKey(pr.Value.ToLower()))
                                        {
                                            pr.Value = FixDecSep((EM_Helpers.SaveConvertToDouble(upratingFactors[pr.Value.ToLower()])).ToString());
                                        }
                                    }
                                }
                                else    // if it is non-market income
                                {
                                    if (uprateType == 2)
                                    {
                                        double val;
                                        if (upratingFactors2.ContainsKey(pr.Value.ToLower()))
                                        {
                                            pr.Value = FixDecSep((EM_Helpers.SaveConvertToDouble(upratingFactors2[pr.Value.ToLower()]) / alpha).ToString());
                                        }
                                        else if (EM_Helpers.TryConvertToDouble(pr.Value.ToLower(), out val))
                                        {
                                            pr.Value = FixDecSep((val / alpha).ToString());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (uprateType > 1)
            {
                string[] monetaryTypes = new string[] { DefPeriod.M, DefPeriod.Y, DefPeriod.Q, DefPeriod.W,
                                                        DefPeriod.D, DefPeriod.L, DefPeriod.S, DefPeriod.C };
                foreach (CountryConfig.FunctionRow fr in sr1.GetPolicyRows().First(p => p.Name.ToLower() == ("Uprate_" + countryShortName).ToLower()).GetFunctionRows())
                {
                    foreach (CountryConfig.ParameterRow pr in fr.GetParameterRows())
                    {
                        string val = pr.Value.ToLower().Trim();
                        if (val.Length < 3)
                        {
                            continue;
                        }
                        string valType = val.Substring(val.Length - 2);

                        if (monetaryTypes.Contains(valType))
                        {
                            val = val.Substring(0, val.Length - 2);
                            if (uprateType == 2)
                            {
                                pr.Value = FixDecSep((EM_Helpers.SaveConvertToDouble(val) / alpha).ToString()) + valType;
                            }
                            else if (uprateType == 3)
                            {
                                pr.Value = FixDecSep((EM_Helpers.SaveConvertToDouble(val) * alpha).ToString()) + valType;
                            }
                        }
                    }
                }
            }
            try
            {
                // Then, fix the output filenames
                sr1.GetPolicyRows().First(p => p.Name.ToLower() == ("output_std_" + countryShortName).ToLower())
                .GetFunctionRows().First(f => f.Name.ToLower() == "defoutput")
                .GetParameterRows().First(p => p.Name.ToLower() == "file")
                .Value = sr1.Name + "_std";
                sr1.GetPolicyRows().First(p => p.Name.ToLower() == ("output_std_hh_" + countryShortName).ToLower())
                .GetFunctionRows().First(f => f.Name.ToLower() == "defoutput")
                .GetParameterRows().First(p => p.Name.ToLower() == "file")
                .Value = sr1.Name + "_std_hh";
                // Finally, if required, do the scaling
                if (checkRadioMarket.Checked)
                {
                    CountryConfig.FunctionRow fr = sr1.GetPolicyRows().First(p => p.Name.ToLower() == ("output_std_" + countryShortName).ToLower())
                                                   .GetFunctionRows().First(f => f.Name.ToLower() == "defoutput");
                    CountryConfig.FunctionRow fr_hh = sr1.GetPolicyRows().First(p => p.Name.ToLower() == ("output_std_hh_" + countryShortName).ToLower())
                                                      .GetFunctionRows().First(f => f.Name.ToLower() == "defoutput");

                    if (fr.GetParameterRows().Count(p => p.Name.ToLower() == DefPar.DefOutput.MultiplyMonetaryBy.ToLower()) == 0)
                    {
                        CountryConfig.ParameterRow fpr = fr.GetParameterRows().First(p => p.Name.ToLower() == "file");
                        CountryConfig.ParameterRow cpr = CountryConfigFacade.AddParameterRow(fpr, false,
                                                                                             DefPar.DefOutput.MultiplyMonetaryBy, DefinitionAdmin.GetParDefinition(DefFun.DefOutput, DefPar.DefOutput.MultiplyMonetaryBy));
                        cpr.Value = FixDecSep((1 / alpha).ToString());
                    }
                    else
                    {
                        CountryConfig.ParameterRow mpr = fr.GetParameterRows().First(p => p.Name.ToLower() == DefPar.DefOutput.MultiplyMonetaryBy.ToLower());
                        double d;
                        if (!EM_Helpers.TryConvertToDouble(mpr.Value, out d))
                        {
                            d = 1;
                        }
                        mpr.Value = FixDecSep((d / alpha).ToString());
                    }

                    if (fr_hh.GetParameterRows().Count(p => p.Name.ToLower() == DefPar.DefOutput.MultiplyMonetaryBy.ToLower()) == 0)
                    {
                        CountryConfig.ParameterRow fpr_hh = fr_hh.GetParameterRows().First(p => p.Name.ToLower() == "file");
                        CountryConfig.ParameterRow cpr    = CountryConfigFacade.AddParameterRow(fpr_hh, false,
                                                                                                DefPar.DefOutput.MultiplyMonetaryBy, DefinitionAdmin.GetParDefinition(DefFun.DefOutput, DefPar.DefOutput.MultiplyMonetaryBy));
                        cpr.Value = FixDecSep((1 / alpha).ToString());
                    }
                    else
                    {
                        CountryConfig.ParameterRow mpr_hh = fr_hh.GetParameterRows().First(p => p.Name.ToLower() == DefPar.DefOutput.MultiplyMonetaryBy.ToLower());
                        double d;
                        if (!EM_Helpers.TryConvertToDouble(mpr_hh.Value, out d))
                        {
                            d = 1;
                        }
                        mpr_hh.Value = FixDecSep((d / alpha).ToString());
                    }
                }
            }
            catch
            {
                throw new Exception("Problem in default output functions.");
            }
        }
        void AddILToMatrix(string ILName, CountryConfig.FunctionRow ILDefFunctionRow,
                           Dictionary <string, CountryConfig.FunctionRow> ILNamesAndILDefFunctionRows,
                           ref Dictionary <string, Dictionary <string, double> > matrix, double inhertitedFactor = 1)
        {
            foreach (CountryConfig.ParameterRow ILDefParameterRow in ILDefFunctionRow.GetParameterRows())
            {
                if (ILDefParameterRow.Name.ToLower() == DefPar.DefIl.Name.ToLower())
                {
                    continue;
                }

                string ILEntry = string.Empty;
                double factor  = 0;

                //new style: incomelist entry (i.e. variable or incomelist) stored in parameter.Name, factor stored in parameter.Value
                if (EM_Helpers.IsNumeric(ILDefParameterRow.Value) ||
                    ILDefParameterRow.Value == "+" || ILDefParameterRow.Value == "-")
                {
                    if (ILDefParameterRow.Value == "+")
                    {
                        factor = inhertitedFactor;
                    }
                    else if (ILDefParameterRow.Value == "-")
                    {
                        factor = inhertitedFactor * -1.0;
                    }
                    else
                    {
                        factor = inhertitedFactor * EM_Helpers.SaveConvertToDouble(ILDefParameterRow.Value);
                    }
                    ILEntry = ILDefParameterRow.Name.ToLower();
                }

                //old style: incomelist entry (i.e. variable or incomelist) stored in parameter.Value, +/- stored in parameter.Name, factor stored in parameter.Group
                else
                {
                    if (ILDefParameterRow.Group == string.Empty)
                    {
                        factor = inhertitedFactor;
                    }
                    else
                    {
                        factor = inhertitedFactor * EM_Helpers.SaveConvertToDouble(ILDefParameterRow.Group); //either there is a factor in the group column or factor is 1
                    }
                    if (ILDefParameterRow.Name.StartsWith("-"))
                    {
                        factor = inhertitedFactor * (-1);
                    }
                    else if (!ILDefParameterRow.Name.StartsWith("+"))
                    {
                        continue; //should not happen
                    }
                    ILEntry = ILDefParameterRow.Value.ToLower();
                }

                if (ILNamesAndILDefFunctionRows.Keys.Contains(ILEntry))
                {
                    AddILToMatrix(ILName, ILNamesAndILDefFunctionRows[ILEntry], ILNamesAndILDefFunctionRows, ref matrix, factor); //recursive call: break incomelist down in its variables
                }
                else
                {
                    if (!matrix.Keys.Contains(ILEntry))
                    {//variable not yet in matrix: add a variable-row with a column for each incomelist (cell is empty if variable is not contained in an incomelist)
                        Dictionary <string, double> variableNamesAndInitialValues = new Dictionary <string, double>();
                        foreach (string variableName in ILNamesAndILDefFunctionRows.Keys)
                        {
                            variableNamesAndInitialValues.Add(variableName, 0);
                        }
                        matrix.Add(ILEntry, variableNamesAndInitialValues);
                    }
                    matrix[ILEntry][ILName] += factor;
                }
            }
        }