Beispiel #1
0
        /// <summary> ////////////////////////////////////////////////////////////////////////////////////
        /// readFile04_Parameters
        /// Loads default parameter values from the defaultFile into the Parms dictionary.
        /// The defaultParms dictionary key is the name of the variable, and the value is a List,
        /// each entry of which is a List.  The bottom level List can contain any number of
        /// elements.  It is up to code elsewhere in the simulation to correctly parse these entries.
        /// Note - input file lines that do not start with a LETTER are ignored - hence, treated as comments.
        /// </summary> ////////////////////////////////////////////////////////////////////////////////////
        static private bool readFile04_Parameters(string fileName)
        {
            FileStream   myFile     = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            StreamReader fileReader = new StreamReader(myFile);
            int          lineNum    = 1; // Keep track of where we are in the file in case there is a problem

            // Read in first line of file.
            string inputRecord = fileReader.ReadLine();

            // If file is empty, return with error
            if (inputRecord == null)
            {
                Console.WriteLine("Error - File contains no data.");
                Console.WriteLine("File name was: {0}", fileName);
                Console.WriteLine("");
                Console.ReadKey();
                return(false);
            }

            // Read until reaching the end of file.  Report errors and exit if any line has bad data
            while (inputRecord != null)
            {
                if (!Parms.addNewParm(inputRecord, lineNum))
                {
                    return(false);
                }
                inputRecord = fileReader.ReadLine();
                lineNum++;
            }

            // No errors encountered - so return true
            return(true);
        }
Beispiel #2
0
 /// <summary> //////////////////////////////////////////////////////////////////////////
 /// Reports out number of subjects simulated at specified interval.
 /// </summary> /////////////////////////////////////////////////////////////////////////
 private static void reportSimProgress(int numSimulated)
 {
     if (numSimulated % Parms.getParmDouble("Sim_OutputInterval") == 0)
     {
         Console.WriteLine("Simulated {0} of {1} subjects",
                           numSimulated, Parms.getParmDouble("Sim_NumSubjects"));
     }
 }
        /// <summary>
        /// loopThroughPolicies - for each policy in the PolicyList, procedure
        /// extracts policy information, runs simulation, and reports results.
        /// </summary>
        static public void loopThroughPolicies()
        {
            // Static globals for simulation
            discountRatePerYr = Parms.getParmDouble("discountRate");
            deltaTime         = Parms.getParmDouble("deltaTime");
            debugOn           = Convert.ToBoolean(Parms.getParmDouble("DebugOn"));
            int Sim_NumSubjects = (int)Parms.getParmDouble("Sim_NumSubjects");

            setUpStatList();

            foreach (Policy myPolicy in Policy.PolicyList)
            {
                initResultsList();
                runSim(myPolicy);
                reportAllStats(myPolicy);
            }
        }