Ejemplo n.º 1
0
        private void Initial(string domainFileName, string problemFileName, string programFileName)
        {
            CUDD.InitialiseCUDD(3072, 256, 262144, 0.1);

            // Create a TextReader that reads from a file
            TextReader tr = new StreamReader(domainFileName);

            // create a CharStream that reads from standard input
            AntlrInputStream input = new AntlrInputStream(tr);
            // create a lexer that feeds off of input CharStream

            PlanningLexer lexer = new PlanningLexer(input);
            // create a buffer of tokens pulled from the lexer
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            // create a parser that feeds off the tokens buffer
            PlanningParser parser = new PlanningParser(tokens);

            var domainContext = parser.domain();// begin parsing at init rule

            tr.Close();

            // Create a TextReader that reads from a file
            tr = new StreamReader(problemFileName);

            // create a CharStream that reads from standard input
            input = new AntlrInputStream(tr);
            // create a lexer that feeds off of input CharStream

            lexer = new PlanningLexer(input);
            // create a buffer of tokens pulled from the lexer
            tokens = new CommonTokenStream(lexer);
            // create a parser that feeds off the tokens buffer
            parser = new PlanningParser(tokens);

            var clientProblemContext = parser.clientProblem();// begin parsing at client problem rule

            //Console.WriteLine(serverProblemContext.ToStringTree(parser));
            tr.Close();
            //Console.ReadLine();
            _problem = ClientProblem.CreateInstance(domainContext, clientProblemContext);
            //_problem.ShowInfo();

            // Create a TextReader that reads from a file
            tr = new StreamReader(programFileName);

            // create a CharStream that reads from standard input
            input = new AntlrInputStream(tr);
            // create a lexer that feeds off of input CharStream

            lexer = new PlanningLexer(input);
            // create a buffer of tokens pulled from the lexer
            tokens = new CommonTokenStream(lexer);
            // create a parser that feeds off the tokens buffer
            parser = new PlanningParser(tokens);

            _programContext = parser.program(); // begin parsing at program rule
            //Console.WriteLine(serverProblemContext.ToStringTree(parser));
            tr.Close();
        }
Ejemplo n.º 2
0
        private void Initial()
        {
            CUDD.InitialiseCUDD(3072, 256, 262144, 0.1);

            // Create a TextReader that reads from a file
            TextReader tr = new StreamReader(_domainFileName);

            // create a CharStream that reads from standard input
            AntlrInputStream input = new AntlrInputStream(tr);
            // create a lexer that feeds off of input CharStream

            PlanningLexer lexer = new PlanningLexer(input);
            // create a buffer of tokens pulled from the lexer
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            // create a parser that feeds off the tokens buffer
            PlanningParser parser = new PlanningParser(tokens);

            var domainContext = parser.domain(); // begin parsing at init rule

            //Console.WriteLine(domainContext.ToStringTree(parser));
            tr.Close();
            //var domain = Domain.CreateInstance(domainContext);
            //ShowDomainInfo(domain);

            // Create a TextReader that reads from a file
            tr = new StreamReader(_serverProblemFileName);

            // create a CharStream that reads from standard input
            input = new AntlrInputStream(tr);
            // create a lexer that feeds off of input CharStream

            lexer = new PlanningLexer(input);
            // create a buffer of tokens pulled from the lexer
            tokens = new CommonTokenStream(lexer);
            // create a parser that feeds off the tokens buffer
            parser = new PlanningParser(tokens);

            var serverProblemContext = parser.serverProblem(); // begin parsing at init rule

            tr.Close();

            DateTime starTime = DateTime.Now;

            _problem = ServerProblem.CreateInstance(domainContext, serverProblemContext);
            DateTime endTime = DateTime.Now;

            Console.WriteLine("Compilation time: {0}", endTime.Subtract(starTime));

            _gridCount = Globals.TermInterpreter.NumericConstValueDict["maxLoc"] + 1;

            _server = new Server(_port, _listenBackLog, _problem);

            _server.NewAction       += _server_NewAction;
            _server.NewObservation  += _server_NewObservation;
            _server.AgentTerminated += _server_AgentTerminated;
            _server.Completed       += _server_Completed;
        }
Ejemplo n.º 3
0
        static void Test1(string domainFileName, string problemFileName)
        {
            CUDD.InitialiseCUDD(256, 256, 262144, 0.1);

            // Create a TextReader that reads from a file
            TextReader tr = new StreamReader(domainFileName);

            // create a CharStream that reads from standard input
            AntlrInputStream input = new AntlrInputStream(tr);
            // create a lexer that feeds off of input CharStream

            PlanningLexer lexer = new PlanningLexer(input);
            // create a buffer of tokens pulled from the lexer
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            // create a parser that feeds off the tokens buffer
            PlanningParser parser = new PlanningParser(tokens);

            var domainContext = parser.domain();// begin parsing at init rule

            //Console.WriteLine(domainContext.ToStringTree(parser));
            tr.Close();
            //var domain = Domain.CreateInstance(domainContext);
            //ShowDomainInfo(domain);

            // Create a TextReader that reads from a file
            tr = new StreamReader(problemFileName);

            // create a CharStream that reads from standard input
            input = new AntlrInputStream(tr);
            // create a lexer that feeds off of input CharStream

            lexer = new PlanningLexer(input);
            // create a buffer of tokens pulled from the lexer
            tokens = new CommonTokenStream(lexer);
            // create a parser that feeds off the tokens buffer
            parser = new PlanningParser(tokens);

            var serverProblemContext = parser.serverProblem();// begin parsing at init rule

            //Console.WriteLine(serverProblemContext.ToStringTree(parser));
            tr.Close();
            //Console.ReadLine();
            ServerProblem problem = ServerProblem.CreateInstance(domainContext, serverProblemContext);

            problem.ShowInfo();

            Server server = new Server(port, listenBacklog, problem);

            server.Run();
            Console.ReadLine();
        }