예제 #1
0
        /// <summary>
        /// Writes <see cref="Model"/> partially to text files - only general information about model and
        /// parameter values are written
        /// </summary>
        /// <param name="model"><see cref="Model"/> instance to be written</param>
        /// <param name="providerSettings"><see cref="TextModelProviderSettings"/> with necessary export information</param>
        public static void WriteModel(Model model, TextModelProviderSettings providerSettings)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            if (providerSettings == null)
            {
                throw new ArgumentNullException("providerSettings");
            }

            WriteModelInformation(model, providerSettings.InformationFilePath);
            WriteModelParameters(model, providerSettings.ParametersFilePath);
        }
예제 #2
0
        /// <summary>
        /// Reads calculation results (values of criteria and functional constraints) from text file to the <paramref name="targetModel"/>
        /// </summary>
        /// <param name="targetModel"><see cref="Model"/> instance to read values to</param>
        /// <param name="providerSettings"><see cref="TextModelProviderSettings"/> with full path to the file to be read</param>
        public static void ReadResultToModel(Model targetModel, TextModelProviderSettings providerSettings)
        {
            if (targetModel == null)
            {
                throw new ArgumentNullException("targetModel");
            }

            if (providerSettings == null)
            {
                throw new ArgumentNullException("providerSettings");
            }

            using (FileStream resultFileStream = File.Open(providerSettings.ResultFilePath, FileMode.Open, FileAccess.Read, FileShare.None))
                using (StreamReader resultFileReader = new StreamReader(resultFileStream, Encoding.UTF8))
                {
                    foreach (Experiment experiment in targetModel.Experiments.Values)
                    {
                        ReadValues <Criterion>(targetModel.Criteria.Values, experiment.CriterionValues, resultFileReader);
                        ReadValues <Constraint>(targetModel.FunctionalConstraints.Values, experiment.ConstraintValues, resultFileReader);
                    }
                }
        }