Exemplo n.º 1
0
 public PersonScenarioExperimental(
     IClientFactory clientFactory,
     ITrainerFactory trainerFactory,
     IGetTrainerForClient getTrainerForClient,
     IDatabase database,
     [KeyFilter("FacadeLogger")] ILogger logger)
 {
     this.clientFactory       = clientFactory;
     this.trainerFactory      = trainerFactory;
     this.getTrainerForClient = getTrainerForClient;
     this.database            = database;
     this.logger = logger;
 }
        public InteractionManager(ILogger logger)
        {
            this.trainers = new HashSet<ITrainer>();
            this.students = new HashSet<IStudent>();

            this.studentFactory = new StudentFactory();
            this.trainerFactory = new TrainerFactory();
            this.petFactory = new PetFactory();

            this.logger = logger;

            GeneratePreviousYearTrainers();
        }
Exemplo n.º 3
0
        public InteractionManager(ILogger logger)
        {
            this.trainers = new HashSet <ITrainer>();
            this.students = new HashSet <IStudent>();

            this.studentFactory = new StudentFactory();
            this.trainerFactory = new TrainerFactory();
            this.petFactory     = new PetFactory();

            this.logger = logger;

            GeneratePreviousYearTrainers();
        }
        private void GaGeneratePredictionsButton_Click(object sender, EventArgs e)
        {
            LockAllTabPages();
            _windowWidth = _gaWindowWidth;
            _operationStart = DateTime.Now;
            _outputFilename = Utilities.OutputFileName("geneGUI.csv");
            _lengthOfPrediction = _gaLengthOfPrediction;
            _startDayIndex = _gaStartDay;
            _trainerFactory = new GeneticTrainerFactory((float)_gaMutationRate, (float)_gaCrossoverRate, _gaIterations);

            _backgroundWorker = new BackgroundWorker();
            _backgroundWorker.WorkerReportsProgress = true;
            _backgroundWorker.WorkerSupportsCancellation = true;
            _backgroundWorker.DoWork += BackgroundWorkerDoWork;
            _backgroundWorker.RunWorkerCompleted += _backgroundWorker_RunWorkerCompleted;

            var progressForm = new ProgressForm(_backgroundWorker);
            progressForm.Show();
        }
        private void AcorGeneratePredictionsButton_Click(object sender, EventArgs e)
        {
            //LockAllTabPagesButMe();
            LockAllTabPages();
            _windowWidth = _acorWindowWidth;
            _operationStart = DateTime.Now;
            _outputFilename = Utilities.OutputFileName("antsGUI.csv");
            _lengthOfPrediction = _acorLengthOfPrediction;
            _startDayIndex = _acorStartDay;
            _trainerFactory = new ACORTrainerFactory(_acorQ, _acorEpsilon, _acorIterations);

            _backgroundWorker = new BackgroundWorker();
            _backgroundWorker.WorkerReportsProgress = true;
            _backgroundWorker.WorkerSupportsCancellation = true;
            _backgroundWorker.DoWork += BackgroundWorkerDoWork;
            _backgroundWorker.RunWorkerCompleted += _backgroundWorker_RunWorkerCompleted;

            var progressForm = new ProgressForm(_backgroundWorker);
            progressForm.Show();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            //CultureInfo culture = new CultureInfo("en");
            //CultureInfo.DefaultThreadCurrentCulture = culture;
            if (args.Length < 1)
            {
                //PrintHelp();
                _mainKasandraForm = new MainKasandraForm();
                Application.EnableVisualStyles();
                //Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(_mainKasandraForm);

            }
            else if(args.Length == 1)
            {
                PrintHelp();
            }
            else
            {

                _inputFilename = args[1].Trim();
                string command = "days";
                if (args.Contains(command))
                {
                    int daysIndex = 0;
                    for (int i = 0; i < args.Length; i++)
                        if (args[i] == command)
                        { daysIndex = i; break; }

                try
                    {
                        _startDayIndex = Int32.Parse(args[daysIndex + 1]);
                        _howManyDaysToPredict = Int32.Parse(args[daysIndex+2]);
                        _teachHowManyDays = Int32.Parse(args[daysIndex + 3]);
                    }
                    catch
                    {
                    }
                }

                switch (args[0])
                {
                    case "a":
                    {
                        _predictionOutputFilename = Utilities.OutputFileName("ants.csv");
                        double q = 0;
                        double epsilon = 0;
                        int archSize = 0;
                        int iterations = 0;

                        bool ok = true;
                        try
                        {
                            q = Double.Parse(args[2]);
                            epsilon = Double.Parse(args[3]);
                            archSize = Int32.Parse(args[4]);
                            iterations = Int32.Parse(args[5]);
                        }
                        catch (Exception)
                        {
                            ok = false;
                        }

                        _trainerFactory = ok ? new ACORTrainerFactory(q, epsilon, iterations, archSize) : new ACORTrainerFactory();
                        if (_parallel)
                        {
                            GeneratePredictionsParallel(_inputFilename, _teachHowManyDays);
                        }
                        else
                        {
                            GeneratePredictionsSequential(_inputFilename, _teachHowManyDays);
                        }

                        break;
                    }
                    case "g":
                    {
                        _predictionOutputFilename = Utilities.OutputFileName("gene.csv");
                        float m = 0;
                        float c = 0;
                        int pmax = 0;
                        int pmin = 0;
                        int iterations = 0;
                        bool ok = true;
                        try
                        {
                            m = (float)Double.Parse(args[2]);
                            c = (float)Double.Parse(args[3]);
                            pmax = Int32.Parse(args[4]);
                            pmin = Int32.Parse(args[5]);
                            iterations = Int32.Parse(args[6]);
                        }
                        catch (Exception)
                        {
                            ok = false;
                        }
                        _trainerFactory = ok ? new GeneticTrainerFactory(m, c, iterations, pmax, pmin) : new GeneticTrainerFactory();
                        if(_parallel)
                            { GeneratePredictionsParallel(_inputFilename, _teachHowManyDays);}
                        else
                            { GeneratePredictionsSequential(_inputFilename, _teachHowManyDays);}
                        break;
                    }
                    case "n":
                    {
                            NormalizeInputFile(_inputFilename);
                            break;
                    }
                    case "i":
                    {
                        string _predictionsFile;
                        try
                        {
                            _predictionsFile = args[2].Trim();
                            if (!File.Exists(_predictionsFile))
                            {
                                Console.WriteLine("Please provide existing file with precalculated predictions");
                                break;
                            }
                        }
                        catch (Exception)
                        {

                            PrintHelp();
                            break;
                        }
                            InvestmentSimulations(_inputFilename, _predictionsFile);
                            break;
                    }
                    case "r":
                    {
                            GenerateRandomPredictions();
                            break;
                    }
                    default:
                    {
                            PrintHelp();
                            break;
                    }
                }
            }

            //return;
        }