Ejemplo n.º 1
0
        public static bool a_star_in_composition(Intarray inputs,
                                                 Intarray vertices1,
                                                 Intarray vertices2,
                                                 Intarray outputs,
                                                 Floatarray costs,
                                                 OcroFST fst1,
                                                 OcroFST fst2)
        {
            CompositionFst composition = FstFactory.MakeCompositionFst(fst1, fst2);
            bool           result;

            try
            {
                //Floatarray g1 = new Floatarray();
                //Floatarray g2 = new Floatarray();
                fst1.CalculateHeuristics();
                fst2.CalculateHeuristics();
                result = a_star2_internal(inputs, vertices1, vertices2, outputs,
                                          costs, fst1, fst2,
                                          fst1.Heuristics(),
                                          fst2.Heuristics(), composition);
            }
            catch (Exception ex)
            {
                composition.Move1();
                composition.Move2();
                throw ex;
            }
            composition.Move1();
            composition.Move2();
            return(result);
        }
Ejemplo n.º 2
0
        public static bool a_star_in_composition(Intarray inputs,
                                                 Intarray vertices1,
                                                 Intarray vertices2,
                                                 Intarray outputs,
                                                 Floatarray costs,
                                                 OcroFST fst1,
                                                 Floatarray g1,
                                                 OcroFST fst2,
                                                 Floatarray g2)
        {
            CompositionFst composition = FstFactory.MakeCompositionFst(fst1, fst2);
            bool           result;

            try
            {
                result = a_star2_internal(inputs, vertices1, vertices2, outputs,
                                          costs, fst1, fst2,
                                          g1,
                                          g2, composition);
            }
            catch (Exception ex)
            {
                composition.Move1();
                composition.Move2();
                throw ex;
            }
            composition.Move1();
            composition.Move2();
            return(result);
        }
Ejemplo n.º 3
0
        public static void a_star_backwards(Floatarray costs_for_all_nodes, IGenericFst fst)
        {
            IGenericFst reverse = FstFactory.MakeOcroFST();

            FstUtil.fst_copy_reverse(reverse, fst, true); // creates an extra vertex
            AStarSearch a = new AStarSearch(reverse);

            a.Loop();
            costs_for_all_nodes.Copy(a.g);
            costs_for_all_nodes.Pop(); // remove the extra vertex
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Compose two FSTs.
        /// This function copies the composition of two given FSTs.
        /// That causes expansion (storing all arcs explicitly).
        /// </summary>
        public static void fst_expand_composition(IGenericFst outf, OcroFST f1, OcroFST f2)
        {
            CompositionFst composition = FstFactory.MakeCompositionFst(f1, f2);

            try
            {
                fst_copy(outf, composition);
            }
            catch (Exception ex)
            {
                composition.Move1();
                composition.Move2();
                throw ex;
            }
            composition.Move1();
            composition.Move2();
        }