public void initSol(problemInstance P) { this.p = P; timeTable = new course[p.Periods_per_day * p.Days][]; for (int i = 0; i < p.Periods_per_day * p.Days; i++) { timeTable[i] = new course[p.Rooms.Length]; } LC = new Dictionary <int, course>(); for (int i = 0; i < p.courses.Length; i++) { LC.Add(i, p.courses[i]);//Algorithm 1 line 3: init LC } nl = new int[p.courses.Length]; nr = new int[p.courses.Length]; nd = new int[p.courses.Length]; for (int i = 0; i < p.courses.Length; i++) { nl[i] = p.courses[i].Lectures;//init nl nr[i] = 0; nd[i] = 0; } initApd(); initArm(); initAps(); initConstraints(); }
public static double getCost(problemInstance p, solution x) { alpha1 = 1; alpha2 = 1; alpha3 = 5; alpha4 = 2; P = p; if (x.apd == null) { X = x; } X = x; return(f()); }
/// <summary> /// read input file and init problemInstance p /// </summary> /// <param name="p">مساله ای که در حال پیدا کردن جواب آن هستیم</param> public void readInput(out problemInstance p) { problemInstance tempP = new problemInstance(); string line; string[] parts; //read name line = IReader.ReadLine(); parts = line.Split(' '); tempP.Name = parts[1]; //read Courses num line = IReader.ReadLine(); parts = line.Split(' '); tempP.CoursesNum = int.Parse(parts[1]); tempP.courses = new course[int.Parse(parts[1])]; //read Rooms line = IReader.ReadLine(); parts = line.Split(' '); tempP.RoomsNum = int.Parse(parts[1]); tempP.Rooms = new room[int.Parse(parts[1])]; //read Days num line = IReader.ReadLine(); parts = line.Split(' '); tempP.Days = int.Parse(parts[1]); //read Periods_per_day num line = IReader.ReadLine(); parts = line.Split(' '); tempP.Periods_per_day = int.Parse(parts[1]); //read Curricula num line = IReader.ReadLine(); parts = line.Split(' '); tempP.CurriculaNum = int.Parse(parts[1]); tempP.Curricula = new Curriculum[int.Parse(parts[1])]; //read Constraints num line = IReader.ReadLine(); parts = line.Split(' '); tempP.ConstraintsNum = int.Parse(parts[1]); tempP.Constraints = new UNAVAILABILITY_CONSTRAINT[int.Parse(parts[1])]; //read courses list while (line != "COURSES:") line = IReader.ReadLine(); for (int i = 0; i < tempP.courses.Length; i++) { line = IReader.ReadLine(); parts = line.Split(' '); tempP.courses[i].CourseID = parts[0]; tempP.courses[i].Teacher = parts[1]; tempP.courses[i].Lectures = int.Parse(parts[2]); tempP.courses[i].MinWorkingDays = int.Parse(parts[3]); tempP.courses[i].Students = int.Parse(parts[4]); } //read rooms list while (line != "ROOMS:") line = IReader.ReadLine(); for (int i = 0; i < tempP.Rooms.Length; i++) { line = IReader.ReadLine(); parts = line.Split(' '); tempP.Rooms[i].ID = parts[0]; tempP.Rooms[i].Capacity = int.Parse(parts[1]); } //read Curriculums list while (line != "CURRICULA:") line = IReader.ReadLine(); for (int i = 0; i < tempP.Curricula.Length; i++) { line = IReader.ReadLine(); parts = line.Split(' '); tempP.Curricula[i].ID = parts[0]; tempP.Curricula[i].Courses = parts.Skip(2).Take(parts.Length - 2).ToArray(); } //read Constraints list while (line != "UNAVAILABILITY_CONSTRAINTS:") line = IReader.ReadLine(); for (int i = 0; i < tempP.Constraints.Length; i++) { line = IReader.ReadLine(); parts = line.Split(' '); tempP.Constraints[i].CourseID = parts[0]; tempP.Constraints[i].Day = int.Parse(parts[1]); tempP.Constraints[i].Day_Period = int.Parse(parts[2]); } IReader.Close();//end of file. p = tempP; }
public void initSol(problemInstance P) { this.p = P; timeTable = new course[p.Periods_per_day * p.Days][]; for (int i = 0; i < p.Periods_per_day * p.Days; i++) { timeTable[i] = new course[p.Rooms.Length]; } LC = new Dictionary<int, course>(); for (int i = 0; i < p.courses.Length; i++) { LC.Add(i, p.courses[i]);//Algorithm 1 line 3: init LC } nl = new int[p.courses.Length]; nr = new int[p.courses.Length]; nd = new int[p.courses.Length]; for (int i = 0; i < p.courses.Length; i++) { nl[i] = p.courses[i].Lectures;//init nl nr[i] = 0; nd[i] = 0; } initApd(); initArm(); initAps(); initConstraints(); }
public static double getCost(problemInstance p, solution x) { alpha1 = 1; alpha2 = 1; alpha3 = 5; alpha4 = 2; P = p; if (x.apd == null) { X = x; } X = x; return f(); }
/// <summary> /// read input file and init problemInstance p /// </summary> /// <param name="p">مساله ای که در حال پیدا کردن جواب آن هستیم</param> public void readInput(out problemInstance p) { problemInstance tempP = new problemInstance(); string line; string[] parts; //read name line = IReader.ReadLine(); parts = line.Split(' '); tempP.Name = parts[1]; //read Courses num line = IReader.ReadLine(); parts = line.Split(' '); tempP.CoursesNum = int.Parse(parts[1]); tempP.courses = new course[int.Parse(parts[1])]; //read Rooms line = IReader.ReadLine(); parts = line.Split(' '); tempP.RoomsNum = int.Parse(parts[1]); tempP.Rooms = new room[int.Parse(parts[1])]; //read Days num line = IReader.ReadLine(); parts = line.Split(' '); tempP.Days = int.Parse(parts[1]); //read Periods_per_day num line = IReader.ReadLine(); parts = line.Split(' '); tempP.Periods_per_day = int.Parse(parts[1]); //read Curricula num line = IReader.ReadLine(); parts = line.Split(' '); tempP.CurriculaNum = int.Parse(parts[1]); tempP.Curricula = new Curriculum[int.Parse(parts[1])]; //read Constraints num line = IReader.ReadLine(); parts = line.Split(' '); tempP.ConstraintsNum = int.Parse(parts[1]); tempP.Constraints = new UNAVAILABILITY_CONSTRAINT[int.Parse(parts[1])]; //read courses list while (line != "COURSES:") { line = IReader.ReadLine(); } for (int i = 0; i < tempP.courses.Length; i++) { line = IReader.ReadLine(); parts = line.Split(' '); tempP.courses[i].CourseID = parts[0]; tempP.courses[i].Teacher = parts[1]; tempP.courses[i].Lectures = int.Parse(parts[2]); tempP.courses[i].MinWorkingDays = int.Parse(parts[3]); tempP.courses[i].Students = int.Parse(parts[4]); } //read rooms list while (line != "ROOMS:") { line = IReader.ReadLine(); } for (int i = 0; i < tempP.Rooms.Length; i++) { line = IReader.ReadLine(); parts = line.Split(' '); tempP.Rooms[i].ID = parts[0]; tempP.Rooms[i].Capacity = int.Parse(parts[1]); } //read Curriculums list while (line != "CURRICULA:") { line = IReader.ReadLine(); } for (int i = 0; i < tempP.Curricula.Length; i++) { line = IReader.ReadLine(); parts = line.Split(' '); tempP.Curricula[i].ID = parts[0]; tempP.Curricula[i].Courses = parts.Skip(2).Take(parts.Length - 2).ToArray(); } //read Constraints list while (line != "UNAVAILABILITY_CONSTRAINTS:") { line = IReader.ReadLine(); } for (int i = 0; i < tempP.Constraints.Length; i++) { line = IReader.ReadLine(); parts = line.Split(' '); tempP.Constraints[i].CourseID = parts[0]; tempP.Constraints[i].Day = int.Parse(parts[1]); tempP.Constraints[i].Day_Period = int.Parse(parts[2]); } IReader.Close();//end of file. p = tempP; }