Example #1
0
 public BreadthFirstSearch(QueueSearch <S, A> impl)
     : base(impl, CollectionFactory.CreateFifoQueue <Node <S, A> >())
 {
     // Goal test is to be applied to each node when it is generated
     // rather than when it is selected for expansion.
     impl.setEarlyGoalTest(true);
 }
Example #2
0
        // persistent: percepts, a sequence, initially empty table, a table
        // of actions, indexed by percept sequences, initially fully specified

        /// <summary>
        /// Constructs a TableDrivenAgentProgram with a table of actions, indexed by percept sequences.
        /// </summary>
        /// <param name="perceptSequenceActions">a table of actions, indexed by percept sequences</param>
        public TableDrivenAgentProgram(IMap <ICollection <IPercept>, IAction> perceptSequenceActions)
        {
            ICollection <ICollection <IPercept> > rowHeaders
                = CollectionFactory.CreateQueue <ICollection <IPercept> >(perceptSequenceActions.GetKeys());

            ICollection <string> colHeaders = CollectionFactory.CreateFifoQueue <string>();

            colHeaders.Add(ACTION);

            table = new Table <ICollection <IPercept>, string, IAction>(rowHeaders, colHeaders);

            foreach (ICollection <IPercept> row in rowHeaders)
            {
                table.Set(row, ACTION, perceptSequenceActions.Get(row));
            }
        }
Example #3
0
        /**
         * Reduces the domain of the specified variable to the specified value and
         * reestablishes arc-consistency. It is assumed that the provided CSP was
         * arc-consistent before the call.
         *
         * @return An object which indicates success/failure and contains data to
         *         undo the operation.
         */
        public IInferenceLog <VAR, VAL> apply(CSP <VAR, VAL> csp, Assignment <VAR, VAL> assignment, VAR var)
        {
            Domain <VAL> domain = csp.getDomain(var);
            VAL          value  = assignment.getValue(var);

            if (!domain.contains(value))
            {
                throw new Exception("domain does not contain value");
            }

            DomainLog <VAR, VAL> log = new DomainLog <VAR, VAL>();

            if (domain.size() > 1)
            {
                ICollection <VAR> queue = CollectionFactory.CreateFifoQueue <VAR>();
                queue.Add(var);
                log.storeDomainFor(var, domain);
                csp.setDomain(var, new Domain <VAL>(value));
                reduceDomains(queue, csp, log);
            }
            return(log.compactify());
        }
Example #4
0
 /// <summary>
 /// Creates a new empty graph.
 /// </summary>
 public LabeledGraph()
 {
     globalEdgeLookup = CollectionFactory.CreateInsertionOrderedMap <VertexLabelType, IMap <VertexLabelType, EdgeLabelType> >();
     vertexLabels     = CollectionFactory.CreateFifoQueue <VertexLabelType>();
 }