예제 #1
0
 public static TestFunctionGetter getInstance(string testName)
 {
     if (instance == null)
     {
         instance = new TestFunctionGetter(testName);
     }
     instance.testName = testName;
     return(instance);
 }
예제 #2
0
        static void Main(string[] args)
        {
            learnFunctions = new string[] { LG_FUNC };
            testFunction   = LG_FUNC;
            Console.WriteLine("Please write path to config file:");
            configFile = Console.ReadLine();
            Console.WriteLine("Please write path to points file:");
            pointFile = Console.ReadLine();
            Console.WriteLine(testFunction + " Test START");

            IParser parser = new Parser();
            IConfig config = parser.parseConfig(configFile);
            Task    task   = parser.parseTask(pointFile, config);

            task.function = TestFunctionGetter.getInstance(testFunction).GetFunc();

            foreach (string func in TestFunctionGetter.funcsWithTable)
            {
                if (learnFunctions.Contains(func) || testFunction == func)
                {
                    Console.WriteLine("Please write path to table file for function " + func);
                    string pathToTable = Console.ReadLine();
                    TestFunctionGetter.getInstance(func).SetTable(parser.parseTable(pathToTable, config));
                    break;
                }
            }

            ISolver solver = new Solver();

            solver.setConfig(config);

            Func <double[], double[]>[] functions = new Func <double[], double[]> [learnFunctions.Length];
            for (int j = 0; j < learnFunctions.Length; j++)
            {
                functions[j] = TestFunctionGetter.getInstance(learnFunctions[j]).GetFunc();
            }
            solver.setCLassifier(functions, task);

            int    i      = 0;
            double maxErr = 10;

            Console.WriteLine(config.Approximation > 0.8);
            while (i < 100000000 && maxErr > config.Approximation)
            {
                maxErr = solver.calculate(task);
                Console.WriteLine("maxErr = " + maxErr);
                i++;
            }

            solver.testResult(task.N, task.M, Solver.func);
            Console.WriteLine(testFunction + "Get " + task.points.Length + " points");
            Console.ReadKey();
        }
예제 #3
0
 public Solver()
 {
     func           = TestFunctionGetter.getInstance(Approx.testFunction).GetFunc();
     derivativeFunc = TestFunctionGetter.getInstance(Approx.testFunction).GetDerivative();
 }