Inheritance: ReadOnlyFst
Exemple #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);
        }
        Floatarray g1, g2; // well, that's against our convention,

        #endregion Fields

        #region Constructors

        public AStarCompositionSearch(Floatarray g1, Floatarray g2, CompositionFst c)
            : base(c)
        {
            this.g1 = g1;
            this.g2 = g2;
            this.c = c;
        }
Exemple #3
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);
        }
Exemple #4
0
        internal static bool a_star2_internal(Intarray inputs,
                                              Intarray vertices1,
                                              Intarray vertices2,
                                              Intarray outputs,
                                              Floatarray costs,
                                              IGenericFst fst1,
                                              IGenericFst fst2,
                                              Floatarray g1,
                                              Floatarray g2,
                                              CompositionFst composition)
        {
            Intarray vertices        = new Intarray();
            AStarCompositionSearch a = new AStarCompositionSearch(g1, g2, composition);

            if (!a.Loop())
            {
                return(false);
            }
            if (!a.reconstruct_vertices(vertices))
            {
                return(false);
            }
            a.reconstruct_edges(inputs, outputs, costs, vertices);
            composition.SplitIndices(vertices1, vertices2, vertices);
            return(true);
        }
Exemple #5
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();
        }
Exemple #6
0
 internal static bool a_star2_internal(Intarray inputs,
                   Intarray vertices1,
                   Intarray vertices2,
                   Intarray outputs,
                   Floatarray costs,
                   IGenericFst fst1,
                   IGenericFst fst2,
                   Floatarray g1,
                   Floatarray g2,
                   CompositionFst composition)
 {
     Intarray vertices = new Intarray();
     AStarCompositionSearch a = new AStarCompositionSearch(g1, g2, composition);
     if (!a.Loop())
         return false;
     if (!a.reconstruct_vertices(vertices))
         return false;
     a.reconstruct_edges(inputs, outputs, costs, vertices);
     composition.SplitIndices(vertices1, vertices2, vertices);
     return true;
 }
        CompositionFst c;  // but I let it go since it's so local.

        public AStarCompositionSearch(Floatarray g1, Floatarray g2, CompositionFst c) : base(c)
        {
            this.g1 = g1;
            this.g2 = g2;
            this.c  = c;
        }