示例#1
0
        /// <summary>
        /// Reads an instance file from the given path.
        /// </summary>
        /// <param name="path">The path to the instance file</param>
        /// <returns>The read instance</returns>
        public static Instance ReadJson(string json)
        {
            // Deserialize JSON
            var jsonInstance = JsonIO.From <JsonInstance>(json);

            // Convert and return it
            return(FromJsonInstance(jsonInstance));
        }
示例#2
0
        private static void Execute(Options opts)
        {
            // Read input file (either from file or from stdin)
            var instance = JsonIO.From <JsonCalculation>(string.IsNullOrWhiteSpace(opts.Input) ? Console.In.ReadToEnd() : File.ReadAllText(opts.Input));

            // >> Run calculation
            Action <string> logger = string.IsNullOrWhiteSpace(opts.Output) ? null : Console.Write;
            var             result = Executor.Execute(Instance.FromJsonInstance(instance.Instance), instance.Configuration, logger);

            // Output result
            if (string.IsNullOrWhiteSpace(opts.Output))
            {
                Console.WriteLine(JsonIO.To(result.Solution.ToJsonSolution()));
            }
            else
            {
                File.WriteAllText(opts.Output, JsonIO.To(result.Solution.ToJsonSolution()));
            }
        }