/// <summary> /// Utility evaluation /// </summary> /// <returns> if result<0 : how many constraints are not satisfied /// if result > 0 : how good _order with given density </returns> public int Eval() { int result = 0; /** Negative check: go through every col -> find #t in col -> check for other #t in same col for constraints * each constraint -1 Utilily **/ for (int i = 0; i < _order.GetLength(1); i++) { for (int j = 0; j < _order.GetLength(0); j++) { if (_order[j, i]) { for (int k = j + 1; k < _order.GetLength(0); k++) { if (_order[k, i]) { if (cons.Check_cons(k, j)) { result--; } } } } } } if (result >= 0) { /* High number of lanes diversity */ for (int i = 0; i < _order.GetLength(0); i++) { for (int j = 0; j < _order.GetLength(1); j++) { if (_order[i, j] == true) { result++; j = _order.GetLength(1); } } } // result highest evaluation can be : number of lanes /* High number of lanes active at same time + high density release */ int tempCounter = 0; // how many lanes active at the same time int tempDen = 0; //int[] _denClone = (int[])_density.Clone(); if (result >= _order.GetLength(0)) { for (int i = 0; i < _order.GetLength(1); i++) { for (int j = 0; j < _order.GetLength(0); j++) { if (_order[j, i] == true) { tempCounter++; tempDen += _density[j]; } } result += tempCounter + (tempDen * tempDen); tempCounter = 0; tempDen = 0; } } } return(result); }