public override double Cost(double[] variableCost) { double conflicts = 0.0; foreach (var failures in Variables.Failures) { int nbConflict = failures.Value.Length - 1; if (nbConflict > 0 && !failures.Value.Contains("###")) { conflicts += nbConflict; var words = failures.Key.Split(','); var point = new SetVariables.Point(Int32.Parse(words[0]), Int32.Parse(words[1])); var setBuildings = Variables.BuildingsAt(point); foreach (var index in setBuildings) { variableCost[index] += nbConflict; } } } return(conflicts); }
public override double Cost(double[] variableCost) { // count number of buildings misplaced on unbuildable tiles (denoted by ###) double conflicts = 0.0; int nbConflict; foreach (var failures in Variables.Failures) { if (failures.Value.Contains("###")) { nbConflict = failures.Value.Length - 3; conflicts += nbConflict; var words = failures.Key.Split(','); var point = new SetVariables.Point(Int32.Parse(words[0]), Int32.Parse(words[1])); var setBuildings = Variables.BuildingsAt(point); foreach (var index in setBuildings) { variableCost[index] += nbConflict; } } } return(conflicts); }