private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { //label1.Text = "Dejan"; Raspored temp = new Raspored(best); best.RemoveEvent(podaci, 4); temp.evaluateSchedule(podaci); //temp = podaci.deepCopy(); int[] bad0 = new int[7]; bad0 = temp.evaluateSchedule(podaci); label3.Text = bad0[0].ToString(); label4.Text = bad0[3].ToString(); label5.Text = bad0[1].ToString(); label16.Text = bad0[4].ToString(); //temp.generateHtml("temp.html", podaci); //best = temp.deepCopy(); //Console.WriteLine("{0}", temp.getScore()); int tb = podaci.EventList.Count / 10; int korak = 0; int br = 0; int promjenjeniEvent = 0; bool foo = false; double stop = Double.Parse(textBox1.Text); while (br < numericUpDown1.Value && best.Score < stop) { label2.Text = br.ToString(); progressBar1.PerformStep(); if (foo) continue; bool stuck = true; korak++; //backgroundWorker1.ReportProgress(br); //label2.Text = br.ToString(); br++; //Console.WriteLine("==============="); Raspored eval = new Raspored(temp);//temp.deepCopy(); // Schedule localBest = podaci.deepCopy(); // localBest.evaluateSchedule(); foreach (Event f in podaci.EventList) { int eventId = f.Id; int LecId = f.getLecturer().Id; if (f.tabu != 0 && korak - f.tabu < tb) continue; int t = f.Duration; foreach (Classroom c in podaci.ClassroomList) { //int Roo if (c.canHost(f)) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 12; j++) { //if (c.isAvailable(i, j, t) && f.getLecturer().isAvailable(i, j, t)) if (eval.IsRoomAvailable(c.Id, i, j, t) && eval.IsLecturerAvailable(LecId, i, j, t)) { bool indikator = false; foreach (string g in f.getGroups()) { if (eval.IsGroupAvailable(podaci.findGroup(g).Id, i, j, t) == false) indikator = true; } if (indikator) continue; //TU SMO DAKLE, na eval radim remove //eval.getEventByID(f.getID()).getClassroom().removeEvent(f.getID()); //eval.getEventByID(f.getID()).getLecturer().removeEvent(f.getID()); //eval.getEventByID(f.getID()).getCourse().removeEvent(f.getPlace().i, f.getPlace().j, f.getDuration()); //foreach (string g in f.getGroups()) //{ // eval.findGroup(g).removeEvent(f.getID()); //} eval.RemoveEvent(podaci, eventId); /* Place p = new Place(eval.getRoomByID(c.getID()), i, j); eval.getEventByID(f.getID()).setPlace(p); eval.getRoomByID(c.getID()).setEvent(i, j, f); eval.getEventByID(f.getID()).getLecturer().setEvent(i, j, f); eval.getEventByID(f.getID()).getCourse().setEvent(i, j, f); eval.getEventByID(f.getID()).setClassroom(eval.getRoomByID(c.getID())); foreach (string g in f.getGroups()) { eval.findGroup(g).setEvent(i, j, f); } */ eval.SetEvent(podaci, eventId, c.Id, i, j); bad0 = eval.evaluateSchedule(podaci); if (eval.Score >= best.Score) { label10.Text = bad0[0].ToString(); label11.Text = bad0[3].ToString(); label12.Text = bad0[1].ToString(); label17.Text = bad0[4].ToString(); best = new Raspored(eval); label1.Text = best.Score.ToString().Substring(0, Math.Min(10, best.Score.ToString().Length)); //string html = best.drawGroupSchedule(best.findGroup("MA1_1")); //webBrowser1.DocumentText = html; //Console.WriteLine("{0}", best.getScore()); //best.generateHtml("best.html"); promjenjeniEvent = f.getID(); //f.tabu = 10; stuck = false; //temp.generateHtml("stuck.html", podaci); } /* if (eval.getScore() > localBest.getScore()) { localBest = eval.deepCopy(); }*/ eval = new Raspored(temp); } } } } } } if (stuck) { //best = localBest.deepCopy(); //label1.ForeColor = Color.Red; foo = true; //label2.Text = br.ToString(); int[] bad = new int[7]; bad = best.evaluateSchedule(podaci); label10.Text = bad0[0].ToString(); label11.Text = bad0[3].ToString(); label12.Text = bad0[1].ToString(); label17.Text = bad0[4].ToString(); //temp.generateHtml("stuck.html", podaci); } temp = new Raspored(best); podaci.getEventByID(promjenjeniEvent).tabu = korak; podaci.getEventByID(promjenjeniEvent).F++; //label2.Text = promjenjeniEvent.ToString(); } //label2.Text = "ERROR" + br.ToString(); }
private void button6_Click(object sender, EventArgs e) { best = podaci.timetabler(); int[] bad0 = new int[7]; bad0 = best.evaluateSchedule(podaci); label3.Text = bad0[0].ToString(); label4.Text = bad0[3].ToString(); label5.Text = bad0[1].ToString(); label16.Text = bad0[4].ToString(); button7.Enabled = true; best.view = 1; comboBox1.Items.Clear(); comboBox1.BeginUpdate(); foreach (Group g in podaci.GroupList) { comboBox1.Items.Add(g.getName()); } comboBox1.EndUpdate(); MessageBox.Show("Timetabler je završio", "Obavijest", MessageBoxButtons.OK); }