Example #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 23 + (ActualCost == default(decimal) ? 0 : ActualCost.GetHashCode());
         hash = hash * 23 + (ModifiedDate == default(DateTime) ? 0 : ModifiedDate.GetHashCode());
         hash = hash * 23 + (ProductId == default(int) ? 0 : ProductId.GetHashCode());
         hash = hash * 23 + (Quantity == default(int) ? 0 : Quantity.GetHashCode());
         hash = hash * 23 + (ReferenceOrderId == default(int) ? 0 : ReferenceOrderId.GetHashCode());
         hash = hash * 23 + (ReferenceOrderLineId == default(int) ? 0 : ReferenceOrderLineId.GetHashCode());
         hash = hash * 23 + (TransactionDate == default(DateTime) ? 0 : TransactionDate.GetHashCode());
         hash = hash * 23 + (TransactionType == null ? 0 : TransactionType.GetHashCode());
         return(hash);
     }
 }
Example #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 23 + (ActualCost == null ? 0 : ActualCost.GetHashCode());
         hash = hash * 23 + (ActualEndDate == null ? 0 : ActualEndDate.GetHashCode());
         hash = hash * 23 + (ActualResourceHrs == null ? 0 : ActualResourceHrs.GetHashCode());
         hash = hash * 23 + (ActualStartDate == null ? 0 : ActualStartDate.GetHashCode());
         hash = hash * 23 + (LocationId == default(short) ? 0 : LocationId.GetHashCode());
         hash = hash * 23 + (ModifiedDate == default(DateTime) ? 0 : ModifiedDate.GetHashCode());
         hash = hash * 23 + (OperationSequence == default(short) ? 0 : OperationSequence.GetHashCode());
         hash = hash * 23 + (PlannedCost == default(decimal) ? 0 : PlannedCost.GetHashCode());
         hash = hash * 23 + (ProductId == default(int) ? 0 : ProductId.GetHashCode());
         hash = hash * 23 + (ScheduledEndDate == default(DateTime) ? 0 : ScheduledEndDate.GetHashCode());
         hash = hash * 23 + (ScheduledStartDate == default(DateTime) ? 0 : ScheduledStartDate.GetHashCode());
         hash = hash * 23 + (WorkOrderId == default(int) ? 0 : WorkOrderId.GetHashCode());
         return(hash);
     }
 }
Example #3
0
 /// <summary>
 /// Finds the path in some problem space from a starting state until a goal state has been reached. <para/>
 /// A common application of a heuristic search is implementing path finding.
 /// </summary>
 /// <remarks>
 /// This search implements the famous A* algorithm.
 /// </remarks>
 /// <typeparam name="T">Type of the state elements.</typeparam>
 /// <param name="start">Starting state</param>
 /// <param name="goal">Terminating state.</param>
 /// <param name="getSuccessors">Returns sucessors</param>
 /// <param name="cost">Cost function between two states.</param>
 /// <param name="heuristic">Estimate cost between state and goal state.</param>
 /// <returns>A sequence of states from start (inclusive) to goal (inclusive).</returns>
 public static IReadOnlyList <T> HeuristicSearch <T>(T start, T goal, Func <T, IEnumerable <T> > getSuccessors, ActualCost <T> cost, HeuristicCost <T> heuristic)
 {
     return(HeuristicSearch(start, x => Equals(x, goal), getSuccessors, cost, heuristic));
 }
Example #4
0
        /// <summary>
        /// Finds the path in some problem space from a starting state until a goal condition is satified. <para/>
        /// A common application of a heuristic search is implementing path finding.
        /// </summary>
        /// <remarks>
        /// This search implements the famous A* algorithm.
        /// </remarks>
        /// <typeparam name="T">Type of the state elements.</typeparam>
        /// <param name="start">Starting state</param>
        /// <param name="goalCondition">Search predicate</param>
        /// <param name="getSuccessors">Returns sucessors</param>
        /// <param name="cost">Cost function between two states.</param>
        /// <param name="heuristic">Estimate cost between state and goal state.</param>
        /// <returns>A sequence of states from start (inclusive) to goal (inclusive).</returns>
        public static IReadOnlyList <T> HeuristicSearch <T>(T start, Func <T, bool> goalCondition, Func <T, IEnumerable <T> > getSuccessors, ActualCost <T> cost, HeuristicCost <T> heuristic)
        {
            //
            var nodes = new Dictionary <T, Node <T> >();

            //
            var frontier = new Heap <Node <T> >
            {
                new Node <T>(start)
                {
                    State  = start,
                    FScore = heuristic(start),
                    GScore = 0,
                }
            };

            Node <T> GetNode(T state)
            {
                if (!nodes.TryGetValue(state, out var node))
                {
                    node         = new Node <T>(state);
                    nodes[state] = node;
                }

                return(node);
            }
        //this method update the actual cost field in the actual cost table
        public bool addActualCost(double total, string cm)
        {
            try
            {
                using (adoraDBContext a = new adoraDBContext())
                {
                    ActualCost actCost = new ActualCost();

                    actCost.CM = cm;
                    actCost.TotalCost = Convert.ToDecimal(total);

                    a.ActualCosts.Add(actCost);
                    a.SaveChanges();

                    return true;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                addException(e, "addActualCost()");
                return false;
            }
        }