コード例 #1
0
 protected void Ordering(object sender, EventArgs e)
 {
     if ((sizeDropDownList.SelectedValue != "") && (crustDropDownList.SelectedValue != ""))
     {
         GetOrderInProcess();
         Pizza   currentPizza = InputData.BuildPizza();
         GetCost CurrentCost  = new GetCost();
         CurrentCost.FindCost(currentPizza);
         costLabel.Text = String.Format("{0:C}", CurrentCost.totalCost);
     }
 }
コード例 #2
0
ファイル: Theta.cs プロジェクト: UltraLuke/Final-IA1-AM2
    public List <T> Run(T start, Satisfies satisfies, GetNeighbours getNeighbours, GetCost getcost, Heuristic heuristic, InSight inSight, int watchDong = 500)
    {
        Dictionary <T, float> cost    = new Dictionary <T, float>();
        Dictionary <T, T>     parents = new Dictionary <T, T>();
        PriorityQueue <T>     pending = new PriorityQueue <T>();
        HashSet <T>           visited = new HashSet <T>();

        pending.Enqueue(start, 0);
        cost.Add(start, 0);
        while (!pending.IsEmpty)
        {
            T current = pending.Dequeue();
            watchDong--;
            if (watchDong <= 0)
            {
                return(new List <T>());
            }
            if (satisfies(current))
            {
                return(ConstructPath(current, parents));
            }
            visited.Add(current);
            List <T> neighbours = getNeighbours(current);
            for (int i = 0; i < neighbours.Count; i++)
            {
                T node = neighbours[i];
                if (visited.Contains(node))
                {
                    continue;
                }
                T currParent;
                if (parents.ContainsKey(current) && inSight(parents[current], node))
                {
                    currParent = parents[current];
                }
                else
                {
                    currParent = current;
                }
                float nodeCost  = getcost(currParent, node);
                float totalCost = cost[currParent] + nodeCost;
                if (cost.ContainsKey(node) && cost[node] < totalCost)
                {
                    continue;
                }
                cost[node]    = totalCost;
                parents[node] = currParent;
                pending.Enqueue(node, totalCost + heuristic(node));
            }
        }
        return(new List <T>());
    }
コード例 #3
0
    public List <T> Run(T start, Satisfies satisfies, GetNeighbours getNeighbours, GetCost getCost, Heuristic heuristic, int watchdog = 100)
    {
        Dictionary <T, T>     parents = new Dictionary <T, T>();
        PriorityQueue <T>     pending = new PriorityQueue <T>();
        Dictionary <T, float> cost    = new Dictionary <T, float>();
        HashSet <T>           visited = new HashSet <T>();

        pending.Enqueue(start, 0);
        cost.Add(start, 0);

        while (!pending.IsEmpty)
        {
            watchdog--;
            if (watchdog <= 0)
            {
                return(new List <T>());
            }

            T current = pending.Dequeue();
            if (satisfies(current))
            {
                return(ConstructPath(current, parents));
            }

            visited.Add(current);
            List <T> neighbours = getNeighbours(current);
            for (int i = 0; i < neighbours.Count; i++)
            {
                var item = neighbours[i];
                if (visited.Contains(item))
                {
                    continue;
                }

                float totalCost = cost[current] + getCost(current, item);
                if (cost.ContainsKey(item) && cost[item] < totalCost)
                {
                    continue;
                }

                cost[item]    = totalCost;
                parents[item] = current;
                pending.Enqueue(item, totalCost + heuristic(item));
            }
        }
        return(new List <T>());
    }
コード例 #4
0
ファイル: CostService.cs プロジェクト: aaronzoe/Klkl
 public object Post(GetCost request)
 {
     return Db.SingleById<Cost>(request.ID);
 }