Esempio n. 1
0
        private State initState()
        {
            State s = new State();

            s.matrix = new double[Cities.Length, Cities.Length];
            for (int i = 0; i < Cities.Length; i++)
            {
                for (int j = 0; j < Cities.Length; j++)
                {
                    double entry = Cities[i].costToGetTo(Cities[j]);
                    if (entry == 0)
                    {
                        entry = double.MaxValue;
                    }
                    s.matrix[i, j] = entry;
                }
            }
            s.calculateBound();
            return(s);
        }
Esempio n. 2
0
        private ArrayList generateChildren(State u)
        {
            ArrayList children = new ArrayList();
            int       row      = (int)u.path[(u.path.Count - 1)];

            for (int i = 0; i < Cities.Length; i++)
            {
                if (u.matrix[row, i] != double.MaxValue && !u.path.Contains(i))
                {
                    State child = new State(u);
                    child.path.Add(i);
                    child.boundValue += child.matrix[row, i];
                    for (int j = 0; j < Cities.Length; j++)
                    {
                        child.matrix[row, j] = double.MaxValue;
                        child.matrix[j, i]   = double.MaxValue;
                    }
                    child.calculateBound();
                    children.Add(child);
                }
            }
            return(children);
        }
Esempio n. 3
0
 private State initState()
 {
     State s = new State();
     s.matrix = new double[Cities.Length, Cities.Length];
     for (int i = 0; i < Cities.Length; i++)
     {
         for (int j = 0; j < Cities.Length; j++)
         {
             double entry = Cities[i].costToGetTo(Cities[j]);
             if (entry == 0)
                 entry = double.MaxValue;
             s.matrix[i, j] = entry;
         }
     }
     s.calculateBound();
     return s;
 }
Esempio n. 4
0
 private ArrayList generateChildren(State u)
 {
     ArrayList children = new ArrayList();
     int row = (int)u.path[(u.path.Count-1)];
     for (int i = 0; i < Cities.Length; i++)
     {
         if (u.matrix[row, i] != double.MaxValue && !u.path.Contains(i))
         {
             State child = new State(u);
             child.path.Add(i);
             child.boundValue += child.matrix[row, i];
             for (int j = 0; j < Cities.Length; j++)
             {
                 child.matrix[row, j] = double.MaxValue;
                 child.matrix[j, i] = double.MaxValue;
             }
             child.calculateBound();
             children.Add(child);
         }
     }
     return children;
 }