Exemple #1
0
        public int findOptimalStock()
        {
            double maxExpectation = StocksManager.getStocks().Max(st => st.getExcpectation());
            Stock  s = StocksManager.getStocks().First <Stock>(st => st.getExcpectation() == maxExpectation);

            return(s._id);
        }
        private static void initScenariosInDB()
        {
            int scenariosNumber = int.Parse(ConfigurationManager.AppSettings["NumberOfScenarios"]);
            int turnsNum        = int.Parse(ConfigurationManager.AppSettings["MaxRounds"]);

            List <List <DALType> > writeData = new List <List <DALType> >();

            for (int i = 0; i < scenariosNumber; i++)
            {
                for (int j = 0; j < turnsNum; j++)
                {
                    foreach (Stock s in StocksManager.getStocks())
                    {
                        List <DALType> row = new List <DALType>();

                        row.Add(new DALInt(i + 1));             //scenarioId
                        row.Add(new DALInt(j + 1));             //TurnNum
                        row.Add(new DALInt(s._id));             //srockId
                        row.Add(new DALDouble(s.getEarning())); //stock earning

                        writeData.Add(row);
                    }
                }
            }
            dal.writeData(scenariosTable, writeData);
        }