Exemplo n.º 1
0
    private Vector3 SelectUnassignedVariable()
    {
        List <Vector3> selectedKeys = new List <Vector3>();
        int            maxValCount  = int.MaxValue;

        foreach (Vector3 key in csp.Keys)
        {
            if (csp[key].Count <= maxValCount && csp[key].Count > 1)
            {
                if (csp[key].Count < maxValCount)
                {
                    selectedKeys.Clear();
                }
                selectedKeys.Add(key);
                maxValCount = csp[key].Count;
            }
        }
        Vector3 selectedKey        = Vector3.zero;
        int     maxConstraintCount = int.MinValue;

        foreach (Vector3 key in selectedKeys)
        {
            int nbConstraint = AC3.GetNeighbors(csp, key).Count;
            if (nbConstraint > maxConstraintCount)
            {
                selectedKey        = key;
                maxConstraintCount = nbConstraint;
            }
        }
        return(selectedKey);
    }
Exemplo n.º 2
0
 public sealed override string ToString()
 {
     return("{ AC1: " + AC1.ToString("X") +
            ", AC2: " + AC2.ToString("X") +
            ", AC3: " + AC3.ToString("X") +
            ", AC4: " + AC4.ToString("X") +
            ", AC5: " + AC5.ToString("X") +
            ", AC6: " + AC6.ToString("X") +
            ", VB1: " + B1.ToString("X") +
            ", VB2: " + B2.ToString("X") +
            ", MB: " + MB.ToString("X") +
            ", MC: " + MC.ToString("X") +
            ", MD: " + MD.ToString("X") + " }");
 }
Exemplo n.º 3
0
 public void CallEdit()
 {
     try
     {
         if (ViewState["Flag"].ToString() != "AD")
         {
             DT = RP.GetInfo(ViewState["Id"].ToString(), "Disp", Session["BRCD"].ToString());
             if (DT.Rows.Count > 0)
             {
                 TxtPno.Text = DT.Rows[0]["REC_PRD"].ToString();
                 string AC1;
                 AC1 = LI.Getaccno(TxtPno.Text, Session["BRCD"].ToString());
                 if (AC1 != null)
                 {
                     string[] AC = AC1.Split('_');;
                     TxtRecPname.Text = AC[1].ToString();
                 }
                 TxtPostPrd.Text = DT.Rows[0]["POST_PRD"].ToString();
                 string AC2;
                 AC2 = LI.Getaccno(TxtPostPrd.Text, Session["BRCD"].ToString());
                 if (AC2 != null)
                 {
                     string[] ACp = AC2.Split('_');;
                     TxtPname.Text = ACp[1].ToString();
                 }
                 string AC3;
                 TxtExrec.Text = DT.Rows[0]["EXRECCODE"].ToString();
                 AC3           = LI.Getaccno(TxtExrec.Text, Session["BRCD"].ToString());
                 if (AC3 != null)
                 {
                     string[] ACe = AC3.Split('_');;
                     TxtEname.Text = ACe[1].ToString();
                 }
                 TxtCol.Text    = DT.Rows[0]["COLUMNNO"].ToString();
                 TxtShort.Text  = DT.Rows[0]["SHORTNAME"].ToString();
                 TxtMarati.Text = DT.Rows[0]["SHORTMARATHI"].ToString();
                 Txtvalue.Text  = DT.Rows[0]["VALUE"].ToString();
                 Txttype.Text   = DT.Rows[0]["TYPE"].ToString();
                 Txtrate.Text   = DT.Rows[0]["RATE"].ToString();
             }
         }
     }
     catch (Exception Ex)
     {
         ExceptionLogging.SendErrorToText(Ex);
     }
 }
Exemplo n.º 4
0
    private IEnumerable <Room> OrderDomainValues(Vector3 position)
    {
        List <CountedRoom> sortedRoom = new List <CountedRoom>();
        Queue <Arc>        arcs       = AC3.GetNeighbors(csp, position);
        List <Room>        neighbors  = new List <Room>();

        while (arcs.Count > 0)
        {
            neighbors.Concat <Room>(csp[arcs.Dequeue().roomJ]);
        }
        foreach (Room room in csp[position])
        {
            sortedRoom.Add(new CountedRoom(CountRoom(room.GetType(), neighbors), room));
        }
        sortedRoom.Sort();
        Queue <Room> output = new Queue <Room>();

        foreach (CountedRoom cr in sortedRoom)
        {
            output.Enqueue(cr.room);
        }
        return(output);
    }
Exemplo n.º 5
0
    private Dictionary <Vector3, Room> RecursiveBacktracking(Dictionary <Vector3, Room> assignment, Dictionary <Vector3, List <Room> > csp)
    {
        AC3.Execute(ref csp);
        if (CheckAssignment(assignment))
        {
            return(assignment);
        }
        bool partialyComplete = false;

        if (CheckPartialAssignment(assignment))
        {
            partialyComplete = true;
            if (partialCounter > partialMax)
            {
                return(assignment);
            }
        }
        if (HasNullValue(csp))
        {
            //return new Dictionary<Vector3, List<Room>>();
            if (partialyComplete)
            {
                partialCounter++;
            }
            return(new Dictionary <Vector3, Room>());
        }
        Vector3 variable = SelectUnassignedVariable();

        if (variable == Vector3.zero)
        {
            Debug.Log("No variable found during the recursivebacktracking");
            if (partialyComplete)
            {
                partialCounter++;
            }
            //return new Dictionary<Vector3, List<Room>>();
            return(new Dictionary <Vector3, Room>());
        }
        IEnumerable <Room> sortedUnassignedValues = OrderDomainValues(variable);

        foreach (Room value in sortedUnassignedValues)
        {
            //Consistent thanks to AC3
            //if (!assignment.ContainsKey(variable))
            //    assignment.Add(variable, new List<Room>());
            //assignment[variable].Add(value);
            assignment.Add(variable, value);
            List <Room> tmp = new List <Room>(csp[variable]);
            csp[variable].Clear();
            csp[variable].Add(value);
            Dictionary <Vector3, Room> result = RecursiveBacktracking(assignment, csp);
            if (result.Count > 0)
            {
                return(result);
            }
            assignment.Remove(variable);
            csp[variable] = tmp;
        }
        return(new Dictionary <Vector3, Room>());
        //return new Dictionary<Vector3, List<Room>>();
    }