Пример #1
0
        private void ProjectSavedListener(object sender, PackEventArgs e)
        {
            List <string> correlationDatasheet = new List <string>();
            StringWriter  _sw = null;

            //Save CorrelatedData datatable
            string _xmlCorrelationData = "";

            if (_correlationData != null)
            {
                _correlationData.TableName = "CorrelationData";
                _sw = new StringWriter();
                _correlationData.WriteXml(_sw, XmlWriteMode.WriteSchema, false);
                _xmlCorrelationData = _sw.ToString();
                _sw.Close();
                _sw = null;
            }
            correlationDatasheet.Add(_xmlCorrelationData);

            //Save Datasheet info
            _sw = null;
            string _xmlDatasheet = "";

            if (_dataSheetData != null)
            {
                _dataSheetData.TableName = "DataSheetData";
                _sw = new StringWriter();
                _dataSheetData.WriteXml(_sw, XmlWriteMode.WriteSchema, false);
                _xmlDatasheet = _sw.ToString();
                _sw.Close();
                _sw = null;
                _datasheetInfo.XmlDataSheetTable = _xmlDatasheet;
            }
            correlationDatasheet.Add(_xmlDatasheet);

            if (_xmlCorrelationData != null || _datasheetInfo != null)
            {
                e.DictPacked.Add("VBProjectManager", correlationDatasheet);
            }
            else
            {
                throw new Exception("Invalid data table used in Save.");
            }
        }
Пример #2
0
        public void Save(string projectFile, Globals.ProjectType projectType)
        {
            SerializableDictionary <string, object> dictPacked = new SerializableDictionary <string, object>();

            dictPacked.Add("_projectType", projectType);

            if (ProjectSaved != null) //something has been added to the list?
            {
                PackEventArgs e = new PackEventArgs(dictPacked);
                ProjectSaved(this, e);
            }

            FileInfo _fi = new FileInfo(projectFile);

            _projectName = _fi.Name;

            XmlSerializer serializerDict = new XmlSerializer();

            serializerDict.Serialize(dictPacked, projectFile);
        }
Пример #3
0
        /// <summary>
        /// Fires when the app saves a project file
        /// </summary>
        /// <param name="projMgr"></param>
        private void ProjectSavedListener(object sender, PackEventArgs e)
        {
            ModelingInfo localModelingInfo = new ModelingInfo();

            //Not really much to save if no models were generated
            if (((_list == null) || (_list.Count < 1)) && ipyPLSControl.VirginState == true)
                return;

            //if (_projMgr.ModelingInfo == null)
            //    _projMgr.ModelingInfo = new ModelingInfo();

            //if the datasheet is dirty, don't want to save modeling data
            if (!_projMgr.DataSheetInfo.Clean) return;

            //Get the state of the IronPython-based modeling methods
            localModelingInfo.PlsProject = ipyPLSControl.PackProjectState();
            localModelingInfo.ActiveModelingTab = tabControl1.SelectedIndex;

            localModelingInfo.Model = _projMgr.Model;

            localModelingInfo.DependentVariable = _projMgr.ModelDataTable.Columns[1].ColumnName;

            //Save dependent variable transform
            if (rbValMET.Checked)
                localModelingInfo.DependentVariableTransform = Globals.DependentVariableTransforms.none;
            else if (rbLog10ValMET.Checked)
                localModelingInfo.DependentVariableTransform = Globals.DependentVariableTransforms.Log10;
            else if (rbLogeValMET.Checked)
                localModelingInfo.DependentVariableTransform = Globals.DependentVariableTransforms.Ln;
            else if (rbPwrValMET.Checked)
            {
                localModelingInfo.DependentVariableTransform = Globals.DependentVariableTransforms.Power;
                localModelingInfo.PowerTransformExponent = Convert.ToDouble(txtPwrValMET.Text);
            }
            //Save available and independent variables
             localModelingInfo.AvailableVariables = new List<ListItem>();
            for (int i = 0; i < lbAvailableVariables.Items.Count; i++)
                localModelingInfo.AvailableVariables.Add((ListItem)lbAvailableVariables.Items[i]);

            localModelingInfo.IndependentVariables = new List<ListItem>();
            for (int i = 0; i < lbIndVariables.Items.Count; i++)
                localModelingInfo.IndependentVariables.Add((ListItem)lbIndVariables.Items[i]);

            //Save the chromosomes
            if (listBox1.Items.Count > 0)
            {
                localModelingInfo.Chromosomes = new List<List<short>>();
                for (int i = 0; i < _list.Count; i++)
                    localModelingInfo.Chromosomes.Add(_list[i].Chromosome);

                MLRIndividual indiv = _list[0] as MLRIndividual;
                localModelingInfo.DecisionThreshold = indiv.DecisionThreshold;
                localModelingInfo.MandatedThreshold = indiv.MandatedThreshold;
                localModelingInfo.FitnessCriteria = (int)indiv.FitnessCriteria;
                localModelingInfo.MaxGeneValue = indiv.MaxGeneValue;
                localModelingInfo.MaxVIF = indiv.MaxVIF;
                localModelingInfo.NumGenes = indiv.NumGenes;
                localModelingInfo.Accuracy = indiv.Accuracy;
                localModelingInfo.AdjustedR2 = indiv.AdjustedR2;
                localModelingInfo.AIC = indiv.AIC;
                localModelingInfo.AICC = indiv.AICC;
                localModelingInfo.BIC = indiv.BIC;
                localModelingInfo.Press = indiv.Press;
                localModelingInfo.R2 = indiv.R2;
                localModelingInfo.RMSE = indiv.RMSE;
                localModelingInfo.Sensitivity = indiv.Sensitivity;
                localModelingInfo.Specificity = indiv.Specificity;
                localModelingInfo.VIF = indiv.VIF;

                localModelingInfo.SelectedModel = _selectedModelIndex;
            }
            else
            {
                localModelingInfo.Chromosomes = null;
            }

            if (_state == _mlrState.clean)
            {
                _projMgr.TabStates.TabState["Residuals"] = true;
                _projMgr.TabStates.TabState["Prediction"] = true;
            }
            else
            {
                _projMgr.TabStates.TabState["Residuals"] = false;
                _projMgr.TabStates.TabState["Prediction"] = false;
            }
            e.DictPacked.Add("frmModel", localModelingInfo);
        }
Пример #4
0
        private void ProjectSavedListener(object sender, PackEventArgs e)
        {
            List<string> correlationDatasheet = new List<string>();
            StringWriter _sw = null;

            //Save CorrelatedData datatable
            string _xmlCorrelationData = "";
            if (_correlationData != null)
            {
                _correlationData.TableName = "CorrelationData";
                _sw = new StringWriter();
                _correlationData.WriteXml(_sw, XmlWriteMode.WriteSchema, false);
                _xmlCorrelationData = _sw.ToString();
                _sw.Close();
                _sw = null;
            }
            correlationDatasheet.Add(_xmlCorrelationData);

            //Save Datasheet info
            _sw = null;
            string _xmlDatasheet = "";
            if (_dataSheetData != null)
            {
                _dataSheetData.TableName = "DataSheetData";
                _sw = new StringWriter();
                _dataSheetData.WriteXml(_sw, XmlWriteMode.WriteSchema, false);
                _xmlDatasheet = _sw.ToString();
                _sw.Close();
                _sw = null;
                _datasheetInfo.XmlDataSheetTable = _xmlDatasheet;
            }
            correlationDatasheet.Add(_xmlDatasheet);

            if(_xmlCorrelationData != null || _datasheetInfo != null)
                e.DictPacked.Add("VBProjectManager", correlationDatasheet);
            else
                throw new Exception("Invalid data table used in Save.");
        }
Пример #5
0
        public void Save(string projectFile, Globals.ProjectType projectType)
        {
            SerializableDictionary<string, object> dictPacked = new SerializableDictionary<string, object>();

            dictPacked.Add("_projectType", projectType);

            if (ProjectSaved != null) //something has been added to the list?
            {
                PackEventArgs e = new PackEventArgs(dictPacked);
                ProjectSaved(this, e);
            }

            FileInfo _fi = new FileInfo(projectFile);
            _projectName = _fi.Name;

            XmlSerializer serializerDict = new XmlSerializer();
            serializerDict.Serialize(dictPacked, projectFile);
        }
Пример #6
0
        private void ProjectSavedListener(object sender, PackEventArgs e)
        {
            PredInfo localMLRPrediction = new PredInfo();

            //First, check whether there's anything to save.
            if ((_projMgr.Model == null) || (_projMgr.Model.Count <= 0))
            {
                _projMgr.PredictionInfo = null;
                return;
            }

               // PredInfo predInfo = new PredInfo();
            StringWriter sw = null;

            dgvVariables.EndEdit();
            _dtVariables = (DataTable)dgvVariables.DataSource;
            if (_dtVariables != null)
            {
                _dtVariables.AcceptChanges();
                _dtVariables.TableName = "Variables";
                sw = new StringWriter();
                _dtVariables.WriteXml(sw, XmlWriteMode.WriteSchema, false);
                localMLRPrediction.IVData = sw.ToString();
                sw.Close();
            }

            dgvObs.EndEdit();
            _dtObs = (DataTable)dgvObs.DataSource;
            if (_dtObs != null)
            {
                _dtObs.AcceptChanges();
                _dtObs.TableName = "Observations";
                sw = new StringWriter();
                _dtObs.WriteXml(sw, XmlWriteMode.WriteSchema, false);
                localMLRPrediction.ObsData = sw.ToString();
                sw.Close();
            }

            dgvStats.EndEdit();
            _dtStats = (DataTable)dgvStats.DataSource;
            if (_dtStats != null)
            {
                _dtStats.AcceptChanges();
                _dtStats.TableName = "Stats";
                sw = new StringWriter();
                _dtStats.WriteXml(sw, XmlWriteMode.WriteSchema, false);
                localMLRPrediction.StatData = sw.ToString();
                sw.Close();
            }

            localMLRPrediction.RegulatoryStandard = Convert.ToDouble(txtRegStd.Text);
            localMLRPrediction.DecisionCriteria = Convert.ToDouble(txtDecCrit.Text);

            string pwrTrans = txtPower.Text;
            if (String.IsNullOrWhiteSpace(pwrTrans))
                localMLRPrediction.PowerTransform = 1.0;

            if (rbNone.Checked)
                localMLRPrediction.DependentVariableTransform = Globals.DependentVariableTransforms.none;
            else if (rbLog10.Checked)
                localMLRPrediction.DependentVariableTransform = Globals.DependentVariableTransforms.Log10;
            else if (rbLn.Checked)
                localMLRPrediction.DependentVariableTransform = Globals.DependentVariableTransforms.Ln;
            else if (rbPower.Checked)
                localMLRPrediction.DependentVariableTransform = Globals.DependentVariableTransforms.Power;

            e.DictPacked.Add("frmMLRPrediction", localMLRPrediction);
        }