コード例 #1
0
 public double WastedCostUtility(List <Gate> repairAction, SystemState state)
 {
     if (state == null || repairAction == null)
     {
         return(0);
     }
     return(WastedCost(repairAction, state.HelthState) + (1 - state.SystemRepair(repairAction)) * StateCost(state));
 }
コード例 #2
0
        public double WastedCostUtility(RepairAction repairAction, SystemState state)
        {
            if (state == null || repairAction == null)
            {
                return(0);
            }
            double fp        = FPCost(repairAction, state.HealthState);
            double sysNotRep = (1 - state.SystemRepair(repairAction));
            double fn        = FNCost(repairAction, state);

            return(fp + (sysNotRep * fn));
        }
コード例 #3
0
ファイル: AStarVertex.cs プロジェクト: shinitzky/Batch-Repair
        //this function calculates the fvalue of this vertex
        private void calcFval(BatchCostEstimator costEstimator, SystemState state)
        {
            double        overhead = costEstimator.Overhead;
            List <double> l_fp     = new List <double>();
            List <double> l_sr     = new List <double>();

            foreach (Comp c in state.Diagnoses.Components)
            {
                if (!Action.Contains(c))
                {
                    double hs   = state.HealthState.GetCompHealthState(c);
                    double cost = ((1 - hs) * c.Cost);

                    l_fp.Add(cost);
                    l_sr.Add(hs);
                }
            }

            l_sr.Sort();
            l_sr.Reverse();
            l_fp.Sort();

            double fpv     = costEstimator.FPCost(Action, state.HealthState);
            double srv     = state.SystemRepair(Action);
            double fmin    = Wastedcost;
            double sum_hs  = l_sr.Sum();
            double sum_sr  = 0;
            double sum_dfp = 0;
            int    b       = Bound - Depth;
            int    size    = Math.Min(l_fp.Count, l_sr.Count);

            if (b > size || !Bounded)
            {
                b = size;
            }

            for (int i = 0; i < b; i++)
            {
                sum_dfp += l_fp[i];
                sum_sr  += l_sr[i];

                double srvi = sum_sr + srv;
                if (srvi > 1)
                {
                    srvi = 1;
                }

                double fnvi = (sum_hs - sum_sr) * overhead;

                if (fpv + ((1 - srv) * fnvi) > Wastedcost)
                {
                    fnvi = overhead;
                }
                if (fpv + ((1 - srv) * fnvi) > Wastedcost)
                {
                    fnvi = 0;
                }

                double fvi = fpv + sum_dfp + ((1 - srvi) * fnvi);

                if (fvi < fmin)
                {
                    fmin = fvi;
                }
            }
            FVal = fmin;
        }