public static void Main(String[] instr)
        {
            DateTime startTime = DateTime.Now;            //start timer
            
            //create instance of a ModelInterpreter object using the specified file
            //could also pass an XmlDocument here (if the XML was stored in a database
            //instead of a file, for example)
            ModelInterpreter test = new ModelInterpreter("plsexample.xml");

            //display some of the common model information
            Console.WriteLine("Model type: " + test.modeltype);
            Console.WriteLine("Expected Data Size:" + test.inputDataSize);
            
            //how long did it take to parse the XML?
            Console.WriteLine("Preparse Time:" + (DateTime.Now - startTime));

            //create data to pass to the model
            Matrix inmatrix = new Matrix(1, test.inputDataSize);
            for (int i = 0; i < inmatrix.NoCols; i++) { inmatrix[0, i] = i + 1; };
            test.inputdata = inmatrix;

            startTime = DateTime.Now;            //start timer

            //set data and apply model            
            test.inputdata = inmatrix;     //assign input data to object
            test.apply();  //apply model
            
            //how long did it take to apply the model?
            Console.WriteLine("Elapsed Time:" + (DateTime.Now - startTime));

            //Typical outputs for a PLS model:
            /*
            Console.WriteLine("yhat = " + test.results.getVar("yhat"));
            Console.WriteLine("T2 = " + test.results.getVar("T2"));
            Console.WriteLine("Q = " + test.results.getVar("Q"));
            /* */
                 
            //List ALL contents of workspace       
            /* */
            foreach (String name in test.results.varList)
            {
                Console.WriteLine(name + " = \n" + test.results.getVar(name));
            }
            /* */
            Console.WriteLine("Press Enter to end test...");
            Console.Read();

        }
Beispiel #2
0
	protected void RunEigenvectorModel (string file, double[,] yMatrix)
	{
		try
		{
			EigenvectorInterpreter.ModelInterpreter evim = new EigenvectorInterpreter.ModelInterpreter(file);
			evim.inputdata = new MatrixLibrary.Matrix(yMatrix);
			evim.apply();
			EigenvectorInterpreter.Workspace ws = evim.results;
			List<string> varList = ws.varList;
			/*
			System.Text.StringBuilder sb = new System.Text.StringBuilder("EigenvectorInterpreter Workspace variables\r");
			foreach (string s in varList)
			{
				sb.AppendFormat("{0}\r", s);
			}
			AddOutputText(sb.ToString());
			*/
			string property = System.IO.Path.GetFileNameWithoutExtension(file);
			string[] words = property.Split(new char[]{'_'});
			if (words.Length > 1)
			{
				property = words[words.Length - 1];
			}
			if (varList.Contains("yhat"))
			{
				MatrixLibrary.Matrix m = ws.getVar("yhat");
				AddOutputText(string.Format("{0} yhat = {1}\r", property, m.ToString()));
			}
			if( varList.Contains("T2"))
			{
				MatrixLibrary.Matrix m = ws.getVar("T2");
				AddOutputText(string.Format("{0} T2 = {1}\r", property, m.ToString()));
			}
			if (varList.Contains("Q"))
			{
				MatrixLibrary.Matrix m = ws.getVar("Q");
				AddOutputText(string.Format("{0} Q = {1}\r", property, m.ToString()));
			}
		}
		catch(EigenvectorInterpreter.EigenvectorInterpreterExceptions e)
		{
			AddOutputText("EigenvectorInterpreter exception: " + e.Message + "\r");
		}
	}