Example #1
0
        public static void HardcodedSampling(IFunction function, out Instance instance, Parser parser)
        {
            int numVariables = function.GetNumVariables();

            int[] starts = new int[numVariables];
            int[] ends   = new int[numVariables];
            for (int i = 0; i < numVariables; i++)
            {
                starts[i] = HardcodedMin;
                ends[i]   = HardcodedMax;
            }
            List <Sample> samples = SampleFunction(function, starts, ends);

            instance = new Instance(samples.Count, numVariables);
            instance.AddFunction(function.ToString());
            instance.AddSamples(samples);
            parser.FormatAndSaveResult(function.Name(), instance);
        }
Example #2
0
        private void ParseLine(string line, int position)
        {
            if (line.StartsWith(Comment) || line is EmptyLine)
            {
                _instance = new Instance(_numSamples, _numVariables);
                _instance.AddFunction(_functionString);
                return;
            }

            if (line.StartsWith(InstanceInfo))
            {
                ParseInstance(line);
            }
            else if (line.StartsWith(Sample))
            {
                ParseSample(line, position);
            }
            else
            {
                ErrorHandler.TerminateExecution(ErrorCode.ImproperLine, "Line " + position + " is not valid.");
            }
        }