public FitnessViewModel()
 {
     _gpContainer     = new GeneticManagement();
     _activeMatches   = new ObservableCollection <MatchHistory>();
     _finishedMatches = new ObservableCollection <MatchHistory>();
     _scores          = new Dictionary <GeneticTree, float>();
 }
 private void _newPopulation()
 {
     gpData = new GeneticManagement();
     gpData.calculateStatistics();
     populationVM     = new PopulationViewModel(gpData);
     currentViewModel = populationVM;
     OnPropertyChanged("currentViewModel");
 }
        public FitnessViewModel(GeneticManagement gen)
        {
            _gpContainer = gen;

            int popSize = _gpContainer._population.Count;

            if ((popSize & (popSize - 1)) == 0)
            {
                _bracketSize = popSize;
            }
            else
            {
                for (int i = popSize; (popSize & (popSize - 1)) != 0; i--)
                {
                    popSize = i;
                }
                _bracketSize = popSize;
            }


            _activeMatches          = new ObservableCollection <MatchHistory>();
            _finishedMatches        = new ObservableCollection <MatchHistory>();
            _scores                 = new Dictionary <GeneticTree, float>();
            _gpContainer._fitnesses = Enumerable.Repeat(0.5f, (int)_gpContainer._populationSize).ToList();

            BindingOperations.EnableCollectionSynchronization(_activeMatches, collectionLock);
            //BindingOperations.EnableCollectionSynchronization(_finishedMatches, collectionLock);

            foreach (var item in _gpContainer._population)
            {
                _scores.Add(item, 0);
            }

            _highlightedMatch         = null;
            _highlightedMove          = 0;
            _highlightMatchCommand    = new RelayCommand(x => { _setHighlight((MatchHistory)x); }, x => true);
            _highlightForwardCommand  = new RelayCommand(x => { _highlightMove(1); }, x => true);
            _highlightBackwardCommand = new RelayCommand(x => { _highlightMove(-1); }, x => true);
            _beginFitnessCommand      = new RelayCommand(async x => await beginFitnessEvaluation(), x => true);


            MatchHistory empty = new MatchHistory();

            empty.addNewState("................................................................");
            _highlightMatchCommand.Execute(empty);
        }
        public DefaultViewModel()
        {
            gpData = new GeneticManagement();

            entryVM      = new EntryViewModel();
            populationVM = new PopulationViewModel();
            highlightVM  = new HighlightViewModel();
            fitnessVM    = new FitnessViewModel();
            selectionVM  = new SelectionCrossoverViewModel();

            initPopulationCommand = new RelayCommand(x => this._newPopulation(), x => this._canChangeVMToPopulation());
            populationCommand     = new RelayCommand(x => _changeVMToPopulation(x), x => _canChangeVMToPopulation());
            mainMenuCommand       = new RelayCommand(x => this._changeVMToEntry(), x => this._canChangeVMToEntry());
            highlightCommand      = new RelayCommand(x => this._changeVMToHighlight(x), x => this._canChangeVMToHighlight(x));
            fitnessCommand        = new RelayCommand(x => _changeVMToFitness(), x => _canChangeVMToFitness());
            selectionCommand      = new RelayCommand(x => _changeVMToSelection(), x => _canChangeVMToSelection());
            newGenCommand         = new RelayCommand(x => _changeVMToPopulationUpdate(), x => true);

            currentViewModel = entryVM;
            OnPropertyChanged("currentViewModel");
        }
 public PopulationViewModel(GeneticManagement gen)
 {
     _gpContainer = gen;
     initializeSettings();
     OnPropertyChanged("_gpContainer");
 }
Example #6
0
 public SelectionCrossoverViewModel(GeneticManagement gpContainer)
 {
     _gpContainer               = gpContainer;
     highlightTreesCommand      = new RelayCommand(x => highlightTrees(x), x => true);
     highlightSingleTreeCommand = new RelayCommand(x => highlightTree(x), x => true);
 }
Example #7
0
 public SelectionCrossoverViewModel()
 {
     _gpContainer = new GeneticManagement();
 }