/// <summary>
        /// Writes a collection of <see cref="Experiment"/> to XML
        /// </summary>
        /// <param name="experimentCollection">A collection to be written to XML</param>
        /// <param name="modelDocumentRoot"><see cref="XElement"/> instance that represents root of model XML document</param>
        private static void WriteRealExperiments(ExperimentCollection experimentCollection, XElement modelDocumentRoot)
        {
            XElement experimentsCollectionElement = new XElement(Elements.RealExperiments);

            foreach (Experiment experiment in experimentCollection.Values)
            {
                XElement experimentElement = new XElement(Elements.RealExperiment,
                                                          new XAttribute(Attributes.Id, experiment.Id.ToString()),
                                                          new XAttribute(Attributes.Number, experiment.Number.ToString())
                                                          );

                XElement parameterValuesCollectionElement =
                    WriteValueCollection(experiment.ParameterValues, Elements.OptimizationParameterValues, Elements.OptimizationParameterValue);
                experimentElement.Add(parameterValuesCollectionElement);

                XElement criterionValuesCollectionElement =
                    WriteValueCollection(experiment.CriterionValues, Elements.RealCriterionValues, Elements.RealCriterionValue);
                experimentElement.Add(criterionValuesCollectionElement);

                XElement constraintValuesCollectionElement =
                    WriteValueCollection(experiment.ConstraintValues, Elements.FunctionalConstraintValues, Elements.FunctionalConstraintValue);
                experimentElement.Add(constraintValuesCollectionElement);

                WritePropertyCollection(experiment.Properties, experimentElement);

                experimentsCollectionElement.Add(experimentElement);
            }

            modelDocumentRoot.Add(experimentsCollectionElement);
        }
Example #2
0
        internal DialogStatisticCounter(ExperimentCollection collection, string experimentPrefix)
        {
            foreach (var experiment in collection.Experiments)
            {
                if (experiment.Id.StartsWith(experimentPrefix))
                {
                    _experiments.Add(experiment);
                }
            }

            _experiments.Sort((a, b) => a.Id.CompareTo(b.Id));
        }
        internal PhraseLearningDialogProvider(ExperimentCollection collection, params string[] experimentsIds)
        {
            foreach (var experiment in collection.Experiments)
            {
                if (experimentsIds.Contains(experiment.Id))
                {
                    _experiments.Add(experiment);
                }
            }

            _experiments.Sort((a, b) => a.Id.CompareTo(b.Id));
        }
Example #4
0
        internal GraphNavigationDataProvider(ExperimentCollection collection, string experimentPrefix)
        {
            foreach (var experiment in collection.Experiments)
            {
                if (experiment.Id.StartsWith(experimentPrefix))
                {
                    _experiments.Add(experiment);
                }
            }

            _experiments.Sort((a, b) => a.Id.CompareTo(b.Id));

            load();
        }
        internal QuestionDialogProvider(ExperimentCollection collection, QuestionCollection questions, string experimentPrefix)
        {
            _questions = questions;

            foreach (var experiment in collection.Experiments)
            {
                if (experiment.Id.StartsWith(experimentPrefix))
                {
                    _experiments.Add(experiment);
                }
            }

            _experiments.Sort((a, b) => a.Id.CompareTo(b.Id));
        }
Example #6
0
        /// <summary>
        /// Get data, that is associated with given client.
        /// </summary>
        /// <param name="client">Client which data is requested.</param>
        /// <returns>Requested data.</returns>
        public static UserData GetUserData(Client client, ExperimentCollection experiments)
        {
            //TODO maybe distinguish according to IP or browser entropy
            var id = client.SessionID;

            lock (_L_users)
            {
                UserData data;
                if (!_data.TryGetValue(id, out data))
                {
                    _data[id] = data = new UserData(id, experiments);
                }

                return(data);
            }
        }
        /// <summary>
        /// Reads a collection of real <see cref="Experiment"/> from XML
        /// </summary>
        /// <param name="experimentCollection">A collection to be read from XML</param>
        /// <param name="experimentsCollectionElement"><see cref="XElement"/> to read a collection from</param>
        private static void ReadRealExperiments(ExperimentCollection experimentCollection, XElement experimentsCollectionElement)
        {
            IEnumerable <XElement> experimentElements = experimentsCollectionElement.Descendants(Elements.RealExperiment);

            foreach (XElement experimentElement in experimentElements)
            {
                TId id     = TId.Parse(experimentElement.Attribute(Attributes.Id).Value);
                int number = Convert.ToInt32(experimentElement.Attribute(Attributes.Number).Value);

                Experiment experiment = new Experiment(id, number);

                ReadValueCollection(experiment.ParameterValues, Elements.OptimizationParameterValues, Elements.OptimizationParameterValue, experimentElement);
                ReadValueCollection(experiment.CriterionValues, Elements.RealCriterionValues, Elements.RealCriterionValue, experimentElement);
                ReadValueCollection(experiment.ConstraintValues, Elements.FunctionalConstraintValues, Elements.FunctionalConstraintValue, experimentElement);
                ReadPropertyCollection(experiment.Properties, ReadCollectionElement(Elements.Properties, experimentElement, false));

                experimentCollection.Add(experiment);
            }
        }
Example #8
0
 private UserData(string id, ExperimentCollection experiments)
 {
     UserID      = id;
     Experiments = experiments;
 }
Example #9
0
        private static void InitializeExperiments()
        {
            //var simpleQuestions1 = Configuration.LoadSimpleQuestions("questions1.smpq");
            var simpleQuestionsTrain = Configuration.SimpleQuestionsTrain;
            //var extensionQuestions = loadExtensionQuestions(Configuration.SimpleQuestionsTrain_Path);

            var experimentsRootPath = Configuration.ExperimentsRootPath;

            Experiments = new ExperimentCollection(experimentsRootPath,

                                                   /*     //question collection experiment
                                                    *   new QuestionCollectionExperiment(experimentsRootPath, "question_collection", 15, simpleQuestions1),
                                                    *
                                                    *   //question collection experiment
                                                    *   new QuestionCollectionExperiment(experimentsRootPath, "question_collection2", 50, simpleQuestionsTrain),
                                                    *
                                                    *
                                                    *   //full operation question collection experiment
                                                    */
                                                   new QuestionCollectionExperiment(experimentsRootPath, "question_collection_r_1", 100, simpleQuestionsTrain),

                                                   new QuestionCollectionExperiment(experimentsRootPath, "question_collection_r_2", 100, simpleQuestionsTrain),

                                                   new QuestionCollectionExperiment(experimentsRootPath, "question_collection_r_3", 100, simpleQuestionsTrain),

                                                   new QuestionCollectionExperiment(experimentsRootPath, "question_collection_r_4", 100, simpleQuestionsTrain),

                                                   new QuestionCollectionExperiment(experimentsRootPath, "question_collection_r_5", 100, simpleQuestionsTrain),

                                                   new QuestionCollectionExperiment(experimentsRootPath, "question_collection_r_6", 100, simpleQuestionsTrain),

                                                   new QuestionCollectionExperiment(experimentsRootPath, "question_collection_r_7", 100, simpleQuestionsTrain),

                                                   new QuestionCollectionExperiment(experimentsRootPath, "question_collection_r_8", 100, simpleQuestionsTrain),

                                                   new QuestionCollectionExperiment(experimentsRootPath, "question_collection_r_9", 100, simpleQuestionsTrain),

                                                   /* new QuestionCollectionExperiment(experimentsRootPath, "question_collection_r_10", 100, simpleQuestionsTrain),
                                                    * new QuestionCollectionExperiment(experimentsRootPath, "qdd_extension_r_1", 100, simpleQuestionsTrain),
                                                    * new QuestionCollectionExperiment(experimentsRootPath, "qdd_extension_r_2", 100, simpleQuestionsTrain),
                                                    * new QuestionCollectionExperiment(experimentsRootPath, "qdd_extension_r_3", 100, extensionQuestions),
                                                    * new QuestionCollectionExperiment(experimentsRootPath, "qdd_extension_r_4", 100, extensionQuestions),
                                                    * new QuestionCollectionExperiment(experimentsRootPath, "qdd_extension_r_5", 100, extensionQuestions),
                                                    * new AnswerExtractionExperiment(experimentsRootPath, "answer_extraction", 100, simpleQuestionsTrain, Configuration.AnswerExtractor),
                                                    * new GraphNavigationExperiment(experimentsRootPath, "graph_navigation", 100, Configuration.GetQuestionDialogsTrain()),
                                                    * new GraphNavigationExperiment(experimentsRootPath, "edge_requests", 100, Configuration.GetQuestionDialogsTrain()),*/
                                                   /*new PhraseRestaurantExperiment(experimentsRootPath, "phrase_restaurant", 10, exportKnowledge: true, useKnowledge: false),
                                                    * new PhraseRestaurantExperiment(experimentsRootPath, "phrase_restaurant2", 10, exportKnowledge: true, useKnowledge: false),
                                                    * new PhraseRestaurantExperiment(experimentsRootPath, "phrase_restaurant3", 10, exportKnowledge: true, useKnowledge: false),
                                                    * new PhraseRestaurantExperiment(experimentsRootPath, "phrase_restaurant4", 10, exportKnowledge: true, useKnowledge: false),*/
                                                   new LearnRestaurantPropertyExperiment(experimentsRootPath, "learn_restaurant_property", 10, exportKnowledge: true, useKnowledge: false, requestInformation: true),
                                                   new PhraseRestaurantExperiment(experimentsRootPath, "shared_phrase_restaurant1", 10, exportKnowledge: true, useKnowledge: true),
                                                   new PhraseRestaurantExperiment(experimentsRootPath, "shared_phrase_restaurant2", 10, exportKnowledge: true, useKnowledge: true),
                                                   new LearnRestaurantPropertyExperiment(experimentsRootPath, "learn_restaurant_property2", 10, exportKnowledge: true, useKnowledge: true, requestInformation: true),

                                                   new PhraseRestaurantExperiment(experimentsRootPath, "concept_learning1a", 50, exportKnowledge: true, useKnowledge: false),
                                                   new PhraseRestaurantExperiment(experimentsRootPath, "concept_learning2a", 50, exportKnowledge: true, useKnowledge: false),
                                                   new PhraseRestaurantExperiment(experimentsRootPath, "concept_learning1b", 50, exportKnowledge: true, useKnowledge: true),
                                                   new PhraseRestaurantExperiment(experimentsRootPath, "concept_learning2b", 50, exportKnowledge: true, useKnowledge: true),

                                                   new LearnRestaurantPropertyExperiment(experimentsRootPath, "composition_learning0", 50, exportKnowledge: true, useKnowledge: true, requestInformation: false),
                                                   new LearnRestaurantPropertyExperiment(experimentsRootPath, "composition_learning1", 100, exportKnowledge: true, useKnowledge: true, requestInformation: true),
                                                   new LearnRestaurantPropertyExperiment(experimentsRootPath, "composition_learning2", 100, exportKnowledge: true, useKnowledge: true, requestInformation: true),
                                                   new LearnRestaurantPropertyExperiment(experimentsRootPath, "composition_learning3", 100, exportKnowledge: true, useKnowledge: true, requestInformation: true)

                                                   );

            QuestionDialogProvider     = new QuestionDialogProvider(Experiments, simpleQuestionsTrain, "question_collection_r_");
            ConceptLearningDialogs     = new PhraseLearningDialogProvider(Experiments, "concept_learning1a", "concept_learning2a", "concept_learning1b", "concept_learning2b");
            CompositionLearningDialogs = new PhraseLearningDialogProvider(Experiments, "composition_learning0", "composition_learning1", "composition_learning2", "composition_learning3");
        }
Example #10
0
        /// <summary>
        /// Copies values of optimization <see cref="Parameter"/>s from <paramref name="identificationModel"/>
        /// to the <see cref="Experiment"/> instances in <paramref name="destination"/> collection
        /// </summary>
        /// <param name="identificationModel"><see cref="IdentificationModel"/> instance to take values from</param>
        /// <param name="destination">Destination collection (set values to)</param>
        private static void CopyOptimizationParametersValues(IdentificationModel identificationModel, ExperimentCollection destination)
        {
            foreach (IdentificationExperiment experiment in identificationModel.IdentificationExperiments.Values)
            {
                Experiment toModify       = destination[experiment.Id];
                Experiment realExperiment = identificationModel.RealExperiments[experiment.RealExperimentId];

                foreach (KeyValuePair <TId, double> optimizationParameter in realExperiment.ParameterValues)
                {
                    toModify.ParameterValues.Add(optimizationParameter.Key, optimizationParameter.Value);
                }
            }
        }
Example #11
0
        /// <summary>
        /// Creates <see cref="Model"/>'s experiments (<see cref="Experiment"/>) based on the <see cref="IdentificationExperiment"/>
        /// stored in the <paramref name="identificationModel"/> and puts them to the <paramref name="destination"/> collection
        /// </summary>
        /// <param name="identificationModel"><see cref="IdentificationModel"/> instance to take experiments from</param>
        /// <param name="destination">Destination collection (save experiments to)</param>
        /// <param name="identificationParameterIdMap">IDs map for parameters (<see cref="ModelsConverter.CopyParameters"/></param>
        private static void CreateExperiments(IdentificationModel identificationModel, ExperimentCollection destination, IDictionary <TId, TId> identificationParameterIdMap)
        {
            destination.Clear();
            foreach (IdentificationExperiment experiment in identificationModel.IdentificationExperiments.Values)
            {
                // Here we are leaving Custom Properties behind, but that should be fine for now
                Experiment toAdd = new Experiment(experiment.Id, experiment.Number);

                foreach (Parameter identificationParameter in identificationModel.IdentificationParameters.Values)
                {
                    TId parameterId = identificationParameterIdMap[identificationParameter.Id];
                    if (experiment.IdentificationParameterValues.ContainsKey(identificationParameter.Id))
                    {
                        toAdd.ParameterValues.Add(parameterId, experiment.IdentificationParameterValues[identificationParameter.Id]);
                    }
                }

                foreach (AdequacyCriterion criterion in identificationModel.Criteria.Values)
                {
                    if (experiment.AdequacyCriterionValues.ContainsKey(criterion.Id))
                    {
                        toAdd.CriterionValues.Add(criterion.Id, experiment.AdequacyCriterionValues[criterion.Id]);
                    }
                }

                foreach (Constraint constraint in identificationModel.FunctionalConstraints.Values)
                {
                    if (experiment.ConstraintValues.ContainsKey(constraint.Id))
                    {
                        toAdd.ConstraintValues.Add(constraint.Id, experiment.ConstraintValues[constraint.Id]);
                    }
                }

                destination.Add(toAdd);
            }
        }