예제 #1
0
        public void SaveConfig()
        {
            try
            {
                var xmlDoc = new XmlDocument();
                xmlDoc.Load(_xmlFilePath);

                var setting = xmlDoc.SelectSingleNode("/Config");

                //监测定时器间隔(s)
                var node = setting?.SelectSingleNode("TimerInterval");
                if (node != null)
                {
                    node.InnerText = TimerInterval.ToString();
                }

                //刷新定时器间隔(s)
                node = setting?.SelectSingleNode("UpdateInterval");
                if (node != null)
                {
                    node.InnerText = UpdateInterval.ToString();
                }

                //X坐标轴时间片(minute)
                node = setting?.SelectSingleNode("AxisXSpan");
                if (node != null)
                {
                    node.InnerText = AxisXSpan.ToString();
                }

                //X坐标轴显示步进(minute)
                node = setting?.SelectSingleNode("AxisXStepNumber");
                if (node != null)
                {
                    node.InnerText = AxisXStepNumber.ToString();
                }

                //X坐标轴显示格式
                node = setting?.SelectSingleNode("LabelFormatter");
                if (node != null)
                {
                    node.InnerText = LabelFormatter;
                }

                xmlDoc.Save(_xmlFilePath);

                AxisXStep  = 1.0 * AxisXSpan / AxisXStepNumber;
                AxisXCount = (int)(1.0f * AxisXSpan * Constants.MINUTE_PER_SECOND / TimerInterval);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
예제 #2
0
        private void SetRegistrySettings()
        {
            try
            {
                RegistryKey currentUserKey = Registry.CurrentUser;
                RegistryKey petKey         = currentUserKey.CreateSubKey(LocalSettingsSubKey);

                petKey.SetValue("TimerInterval", TimerInterval.ToString());
                petKey.SetValue("WarnInterval", WarnInterval.ToString());
                petKey.SetValue("WarnThreshold", WarnThreshold.ToString());
                petKey.SetValue("AlertInterval", AlertInterval.ToString());
                petKey.SetValue("AlertThreshold", AlertThreshold.ToString());
                petKey.SetValue("Action", Action);

                petKey.Close();
                currentUserKey.Close();
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #3
0
        public void SaveToXml(string path = "")
        {
            string xmlInput = "<configuration> \n <parallel> serial </parallel>";

            xmlInput += AddNewPropertyValue("linearInput", LinearInput);
            xmlInput += AddNewPropertyValue("license", License);
            xmlInput += AddNewPropertyValue("entropyDir", InputEntropyDir);
            xmlInput += AddNewPropertyValue("objDir", InputObjDir);

            //population sizing
            xmlInput += AddNewPropertyValue("debug_mode", Debug);
            xmlInput += AddNewPropertyValue("use_hboa", Hboa);
            xmlInput += AddNewPropertyValue("initial_popsize", InitPop.ToString());
            xmlInput += AddNewPropertyValue("min_popsize", MinPop.ToString());
            xmlInput += AddNewPropertyValue("max_popsize", MaxPop.ToString());
            xmlInput += AddNewPropertyValue("popsize_scheme", PopScheme);
            xmlInput += AddNewPropertyValue("pop_scaling_factor", PopFactor.ToString());
            xmlInput += AddNewPropertyValue("max_gens", MaxGens.ToString());

            //Design Objectives
            xmlInput += AddNewPropertyValue("test_problem", TestProblem);
            xmlInput += AddNewPropertyValue("nobj", NObj.ToString());

            for (int i = 1; i <= NObj; i++)
            {
                xmlInput += AddNewPropertyValue("obj_tag" + i, ObjTags[i - 1].ToString());
                xmlInput += AddNewPropertyValue("obj_val" + i, ObjVal[i - 1].ToString());
                xmlInput += AddNewPropertyValue("obj_eps" + i, ObjEps[i - 1].ToString());
            }

            xmlInput += AddNewPropertyValue("num_additional_objectives", NAObj.ToString());

            for (int i = 1; i <= NAObj; i++)
            {
                xmlInput += AddNewPropertyValue("aobj1_" + i, AObj1[i - 1].ToString());
                xmlInput += AddNewPropertyValue("aobj" + i + "_2", AObj2[i - 1].ToString());
            }

            xmlInput += AddNewPropertyValue("ncons", NConst.ToString());

            for (int i = 1; i <= NConst; i++)
            {
                xmlInput += AddNewPropertyValue("con_num" + i, ConNum[i - 1].ToString());
                xmlInput += AddNewPropertyValue("con_tot" + i, ConTot[i - 1].ToString());
                xmlInput += AddNewPropertyValue("con_ind" + i, ConInd[i - 1].ToString());
            }

            //Real Decision Variables

            xmlInput += AddNewPropertyValue("nreal", NReal.ToString());
            xmlInput += AddNewPropertyValue("real_pseudo_binary", PseudoBinary);
            xmlInput += AddNewPropertyValue("real_limits", RealLimits);

            if (RealTag != null)
            {
                for (int i = 1; i <= RealTag.Count(); i++)
                {
                    xmlInput += AddNewPropertyValue("real_tag" + i, RealTag[i - 1].ToString());
                    xmlInput += AddNewPropertyValue("real_min" + i, RealMin[i - 1].ToString());
                    xmlInput += AddNewPropertyValue("real_max" + i, RealMax[i - 1].ToString());
                }
            }

            xmlInput += AddNewPropertyValue("real_cross_prob", RealCrossProb.ToString());
            xmlInput += AddNewPropertyValue("real_mut_prob", RealMutProb.ToString());
            xmlInput += AddNewPropertyValue("dist_index_sbx", DistIndexSBX.ToString());
            xmlInput += AddNewPropertyValue("dist_index_poly", DistIndexPoly.ToString());

            //Binary Decision Variables

            xmlInput += AddNewPropertyValue("nbin", NBin.ToString());
            xmlInput += AddNewPropertyValue("bin_limits", BinLimits == true ? " same " : " different ");

            for (int i = 1; i <= NBin; i++)
            {
                xmlInput += AddNewPropertyValue("bin_tag" + i, BinTag[i - 1].ToString());
                xmlInput += AddNewPropertyValue("bin_bit" + i, BinBit[i - 1].ToString());
                xmlInput += AddNewPropertyValue("bin_min" + i, RealMin[i - 1].ToString());
                xmlInput += AddNewPropertyValue("bin_max" + i, RealMax[i - 1].ToString());
            }

            xmlInput += AddNewPropertyValue("bin_cross_prob", BinCrossProb.ToString());
            xmlInput += AddNewPropertyValue("bin_cross_type", BinCrossType);
            xmlInput += AddNewPropertyValue("bin_mut_prob", BinMutProb.ToString());
            xmlInput += AddNewPropertyValue("bin_mut_type", BinMutType);

            //Soft Termination Criteria

            xmlInput += AddNewPropertyValue("inter_run", InterRun);
            xmlInput += AddNewPropertyValue("inter_delta", InterDelta.ToString());
            xmlInput += AddNewPropertyValue("intra_run", IntraRun);
            xmlInput += AddNewPropertyValue("inter_delta", IntraDelta.ToString());

            //Hard Termination Criteria

            xmlInput += AddNewPropertyValue("max_nfe", MaxNfe.ToString());
            xmlInput += AddNewPropertyValue("max_time", MaxTime.ToString());
            xmlInput += AddNewPropertyValue("max_eperf", MaxEperf.ToString());

            //Performance Metrics

            xmlInput += AddNewPropertyValue("conv", Conv);
            xmlInput += AddNewPropertyValue("div", Div);
            xmlInput += AddNewPropertyValue("eperf", Eperf);
            xmlInput += AddNewPropertyValue("edom_eperf", EdomEperf);

            if (DivGrid != null)
            {
                for (int i = 1; i <= DivGrid.Count; i++)
                {
                    xmlInput += AddNewPropertyValue("div_grid" + i, DivGrid[i - 1].ToString());
                }
            }

            if (EperfEps != null)
            {
                for (int i = 1; i <= EperfEps.Count; i++)
                {
                    xmlInput += AddNewPropertyValue("eperf_eps" + i, EperfEps[i - 1].ToString());
                }
            }

            xmlInput += AddNewPropertyValue("eind", Eind);
            xmlInput += AddNewPropertyValue("eind_error", EindError.ToString());
            xmlInput += AddNewPropertyValue("metric_ref", MetricRef);

            //Local File Output

            xmlInput += AddNewPropertyValue("out_dir", OutDir);
            xmlInput += AddNewPropertyValue("out_headers", OutHeaders);
            xmlInput += AddNewPropertyValue("out_all", OutAll ? OutInterval.ToString() : "0");
            xmlInput += AddNewPropertyValue("out_nondom", Nondom ? NondomInterval.ToString() : "0");
            xmlInput += AddNewPropertyValue("out_all_final", AllFinal ? "on" : "off");
            xmlInput += AddNewPropertyValue("out_nondom_final", NondomFinal ? "on" : "off");
            xmlInput += AddNewPropertyValue("out_stats", StatsInterval.ToString());
            xmlInput += AddNewPropertyValue("out_rs", RsStats ? "on" : "off");
            xmlInput += AddNewPropertyValue("out_timer", TimerInterval.ToString());
            xmlInput += AddNewPropertyValue("out_vtk", VtkInterval.ToString());
            xmlInput += AddNewPropertyValue("out_vtk_sflag", SmallFlag);


            //DEMO Parameters

            xmlInput += AddNewPropertyValue("ndata", NData.ToString());



            //End Tag
            xmlInput += "\n </configuration>";

            var doc = XDocument.Parse(xmlInput);

            xmlDoc = doc;

            if (path == string.Empty)
            {
                doc.Save(path + "configuration.xml");
            }
            else
            {
                doc.Save(path);
            }
        }