// -------------------------------------------------------------------------------------
        //                              !!! PRIVATE METHODS !!!
        // -------------------------------------------------------------------------------------

        /// <summary>
        /// set fitness_params to default values
        /// </summary>
        /// <param name="numDigesters">number of digesters on plant</param>
        private void set_params_to_default(/*biogas.plant myPlant*/ int numDigesters)
        {
            // for each digester
            for (int idigester = 0; idigester < numDigesters; idigester++)
            {
                pH_min.Add(6);
                pH_max.Add(9);
                pH_optimum.Add(7.5);

                TS_max.Add(12);       // [% FM]

                VFA_TAC_min.Add(0.0); // [gHAcEq / gCaCO3]
                VFA_TAC_max.Add(0.3); // [gHAcEq / gCaCO3]

                VFA_min.Add(0);       // [gHAcEq]
                VFA_max.Add(5);       // [gHAcEq]

                TAC_min.Add(5);       // [gCaCO3]

                HRT_min.Add(20);      // [d]
                HRT_max.Add(150);     // [d]

                OLR_max.Add(4);       // [kgVS / (m^3 * d)]

                Snh4_max.Add(3);      // [g/l]
                Snh3_max.Add(80e-3);  // [g/l]

                AcVsPro_min.Add(2);   // [mol/mol]
            }

            // andere Parameter werden in fitness_params_properties.cs auf default Werte
            // gesetzt
        }
Beispiel #2
0
        // -------------------------------------------------------------------------------------
        //                              !!! PUBLIC METHODS !!!
        // -------------------------------------------------------------------------------------

        /// <summary>
        /// set fitness params to values read out of a xml file
        /// </summary>
        /// <param name="reader"></param>
        public void getParamsFromXMLReader(ref XmlTextReader reader)
        {
            string xml_tag        = "";
            int    digester_index = 0;

            // do not set params, because plant is not known
            // TODO - macht probleme wenn ein neuer parameter hinzugefügt wird, da dann
            // dessen list leer bleibt
            // im grunde müsste man am ende der funktion die listen füllen, welche
            // leer geblieben sind mit default werten

            bool do_while = true;

            // go through the file
            while (reader.Read() && do_while)
            {
                switch (reader.NodeType)
                {
                case System.Xml.XmlNodeType.Element: // this knot is an element
                    xml_tag = reader.Name;

                    while (reader.MoveToNextAttribute())
                    { // read the attributes, here only the attribute of digester
                      // is of interest, all other attributes are ignored,
                      // actually there usally are no other attributes
                        if (xml_tag == "digester" && reader.Name == "index")
                        {
                            // TODO
                            // index of digester, not used at the moment
                            digester_index = Convert.ToInt32(reader.Value);

                            break;
                        }
                    }

                    if (xml_tag == "weights")
                    {
                        myWeights.getParamsFromXMLReader(ref reader);
                    }
                    else if (xml_tag == "setpoints")
                    {
                        mySetpoints.getParamsFromXMLReader(ref reader);
                    }

                    break;

                case System.Xml.XmlNodeType.Text: // text, thus value, of each element

                    switch (xml_tag)
                    {
                    // TODO - use digester_index here, compare with size of pH_min, ...
                    // here we assume that params are given in the correct
                    // order, thus first the first digester, then the 2nd digester, ...
                    case "pH_min":
                        pH_min.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "pH_max":
                        pH_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "pH_optimum":
                        pH_optimum.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "TS_max":
                        TS_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "VFA_TAC_min":
                        VFA_TAC_min.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "VFA_TAC_max":
                        VFA_TAC_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "VFA_min":
                        VFA_min.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "VFA_max":
                        VFA_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "TAC_min":
                        TAC_min.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "HRT_min":
                        HRT_min.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "HRT_max":
                        HRT_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "OLR_max":
                        OLR_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "Snh4_max":
                        Snh4_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "Snh3_max":
                        Snh3_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "AcVsPro_min":
                        AcVsPro_min.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
                        break;

                    case "TS_feed_max":
                        _TS_feed_max = System.Xml.XmlConvert.ToDouble(reader.Value);
                        break;

                    case "HRT_plant_min":
                        _HRT_plant_min = System.Xml.XmlConvert.ToDouble(reader.Value);
                        break;

                    case "HRT_plant_max":
                        _HRT_plant_max = System.Xml.XmlConvert.ToDouble(reader.Value);
                        break;

                    case "OLR_plant_max":
                        _OLR_plant_max = System.Xml.XmlConvert.ToDouble(reader.Value);
                        break;

                    // read in manurebonus
                    case "manurebonus":
                        _manurebonus = System.Xml.XmlConvert.ToBoolean(reader.Value);
                        break;

                    case "fitness_function":
                        _fitness_function = reader.Value;
                        break;

                    case "nObjectives":
                        _nObjectives = System.Xml.XmlConvert.ToInt32(reader.Value);
                        break;
                        //case "Ndelta":
                        //  _Ndelta = System.Xml.XmlConvert.ToInt32(reader.Value);
                        //  break;
                    }

                    break;

                case System.Xml.XmlNodeType.EndElement: // end of fitness_params
                    if (reader.Name == "fitness_params")
                    {
                        do_while = false; // end while loop
                    }
                    break;
                }
            }
        }