Exemplo n.º 1
0
        private void saveSolutions()
        {
            Selection selection = (Selection)Selection.where (new Query("Selection").addTypeQuery(TypeQuery.select)
                                                              .addCondition("Name", "=", SelectedSolution), typeof(Selection))[0];

            models.TaskTemplate template  = (models.TaskTemplate)models.TaskTemplate.getById(selection.TaskTemplateID, typeof(models.TaskTemplate));
            models.Parameter    parameter = (models.Parameter)models.Parameter.where (new Query("Parameter").addTypeQuery(TypeQuery.select)
                                                                                      .addCondition("TaskTemplateID", "=", Convert.ToString(template.ID)), typeof(models.Parameter))[0];

            for (int i = 0; i < SolvingList.Count; i++)
            {
                var          item = SolvingList[i];
                SelectionRow sr   = new SelectionRow()
                {
                    SelectionID = selection.ID,
                    Number      = i
                };
                sr.save();
                List <string> values = new List <string>();
                values.AddRange(item.X.Select(x => x.Value));
                values.Add(outputValues[i]);
                foreach (string value in values)
                {
                    TaskSLAnswer vp = new TaskSLAnswer()
                    {
                        SelectionRowID  = sr.ID,
                        Value           = value,
                        ParameterID     = parameter.ID,
                        LearnedSolverID = this.SelectedLearning.LearnedSolver.ID
                    };
                    vp.save();
                }
            }
        }
Exemplo n.º 2
0
        public SolveViewModel(models.Task task, models.TaskSolver solver)
        {
            TaskID      = task.ID;
            SolvingList = new ObservableCollection <SolvingInstance>();
            SolverName  = solver.Name;
            TaskName    = task.Name;
            List <LearningInfo>         learningList   = new List <LearningInfo>();
            List <models.LearnedSolver> learnedSolvers = models.LearnedSolver.learnedSolversOfTaskSolverID(solver.ID);

            foreach (models.LearnedSolver learnedSolver in learnedSolvers)
            {
                models.Selection selection = (models.Selection)models.Selection.getById(learnedSolver.SelectionID, typeof(models.Selection));
                List <models.LearningQuality> qualities  = models.LearningQuality.qualitiesOfSolverId(learnedSolver.ID);
                models.LearningScenario       scenario   = (models.LearningScenario)models.LearningScenario.getById(learnedSolver.LearningScenarioID, typeof(models.LearningScenario));
                models.TaskTemplate           template   = (models.TaskTemplate)models.TaskTemplate.getById(selection.TaskTemplateID, typeof(models.TaskTemplate));
                models.LearningQuality        quality    = (qualities != null && qualities.Count > 0) ? qualities[0] : null;
                List <models.Parameter>       parameters = models.Parameter.parametersOfTaskTemplateId(template.ID);
                int outputParam = 0;
                foreach (models.Parameter param in parameters)
                {
                    if (param.IsOutput == 1)
                    {
                        outputParam = param.ID;
                        break;
                    }
                }
                learningList.Add(new LearningInfo
                {
                    SelectionID          = selection.ID,
                    ParameterID          = outputParam,
                    SelectionName        = selection.Name,
                    LearningScenarioName = scenario.Name,
                    PreprocessingName    = template.Name,
                    TestMistake          = (quality != null) ? quality.MistakeTest : 0,
                    TrainMistake         = (quality != null) ? quality.MistakeTrain : 0,
                    ClosingError         = Convert.ToSingle((quality != null) ? quality.ClosingError : 0),
                    TaskTemplate         = template,
                    LearnedSolver        = learnedSolver
                });
            }
            LearningList = learningList.ToArray();
            addHandler   = new ActionHandler(() =>
            {
                SolvingList.Add(new SolvingInstance(this, this.SelectedLearning.TaskTemplate));
                solveHandler.RaiseCanExecuteChanged();
                saveHandler.RaiseCanExecuteChanged();
                SelectedSolution = Solutions[0];
                NotifyPropertyChanged("SelectedSolution");
                NotifyPropertyChanged("Solutions");
            }, e => SelectedLearning != null);

            solveHandler = new ActionHandler(Solve, e => SolvingList.Count > 0);
            saveHandler  = new ActionHandler(saveSolutions, e => SolvingList.Count > 0);

            SelectedSolution = Solutions[0];
        }
Exemplo n.º 3
0
        public SolvingInstance(SolveViewModel vm, models.TaskTemplate template)
        {
            deleteHandler = new ActionHandler(() => vm.DeleteSolvingInstance(this), e => true);
            List <models.Parameter> parameters = models.Parameter.parametersOfTaskTemplateId(template.ID);

            X = new ObservableCollection <X>();
            foreach (models.Parameter par in parameters.Where(par => par.IsOutput == 0))
            {
                X.Add(new X {
                    ParameterDescription = par.Name
                });
            }
            Y = new ObservableCollection <string>(new string[parameters.Count(par => par.IsOutput != 0)]);
        }
Exemplo n.º 4
0
 public ArchiveTemplate(models.TaskTemplate template)
 {
     this.ID   = template.ID;
     this.Name = template.Name;
     this.PreprocessingParameters = template.PreprocessingParameters;
 }