-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStimulatedAnnealing.java
772 lines (649 loc) · 22.4 KB
/
StimulatedAnnealing.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
package fypScheduling;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Random;
import fypScheduling.Event.Type;
public class StimulatedAnnealing {
private Utilities utility;
private SAPopulation baseSolution = new SAPopulation();
private SAPopulation bestSolution = null;
private Map<Integer, Preference> lecPreferenceList;
private Map<Integer, Preference> tutPreferenceList;
private Map<Integer, Preference> labPreferenceList;
private static ArrayList<Integer> solutionTable = new ArrayList<Integer>();
private static ArrayList<Integer> wluVariationTable = new ArrayList<Integer>();
private double temperature = 100;
private double alpha = 0.99;
HashMap<String, Course> courseNumList = new HashMap<String, Course>();
HashMap<String, Faculty> facNameList = new HashMap<String, Faculty>();
HashMap<String, Grouping> groupingList = new HashMap<String, Grouping>();
public StimulatedAnnealing(){
utility = new Utilities();
lecPreferenceList = new HashMap<Integer, Preference>();
tutPreferenceList = new HashMap<Integer, Preference>();
labPreferenceList = new HashMap<Integer, Preference>();
}
public Utilities getUtilites() {
return utility;
}
/*
* SETUP
*/
public void loadDatabase(String size){
try{
//connection to database
Class.forName("com.mysql.jdbc.Driver");
Connection myConn;
if (size == "Test"){
myConn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:8889/fypSchedulingTest", "root", "root");
}
else if(size == "Small"){
//TODO : WHEN DATASET IS READY - SMALL
myConn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:8889/fypSchedulingSmall", "root", "root");
}
else if (size == "Medium"){
//TODO : WHEN DATASET IS READY - MEDIUM
myConn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:8889/fypSchedulingMid", "root", "root");
}
else{
//TODO : WHEN DATASET IS READY - LARGE
myConn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:8889/fypSchedulingBig", "root", "root");
}
//create statement
Statement myStmt = (Statement) myConn.createStatement();
//execute sql query
loadCourse(myStmt);
loadFaculty(myStmt);
loadGrouping(myStmt);
loadVenues(myStmt);
loadHistory(myStmt);
loadPreferenceList();
baseSolution.createRandomIndividuals(utility);
updateWLUAssignedCourse(baseSolution.getList());
for (Event child : baseSolution.getList()) {
utility.getEvents().put(child.getId(), child);
}
}
catch (Exception e) {
e.printStackTrace();
}
}
public void saveEvents() {
try{
//connection to database
Class.forName("com.mysql.jdbc.Driver");
Connection myConn;
myConn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:8889/fypSchedulingBig", "root", "root");
Statement st = myConn.createStatement();
// Use TRUNCATE
String sql = "TRUNCATE event";
// Execute deletion
st.executeUpdate(sql);
for (Event child : utility.getEvents().values()) {
int id = child.getId();
int type = 0;
Event.Type etype = child.getType();
if (etype == Type.LEC) {
type = 1;
}else if (etype == Type.TUT) {
type = 2;
}else {
type = 3;
}
int eventGroupID = child.getEventGroupId();
int size = child.getSize();
String faculty = "";
for (Faculty facChild : child.getFaculty()) {
faculty+=facChild.getName() + ";";
}
faculty = faculty.substring(0, faculty.length()-1);
String course = child.getCourse().getCourseNum();
String grouping = child.getGrouping().getGroupName();
int eventDuration = child.getEventDuration();
double wlu = child.getWLU();
PreparedStatement stmt = myConn.prepareStatement("INSERT INTO event (id, type, eventGroupID, size, faculty, course, grouping, eventDuration, wlu) VALUES (?, ?, ?,?, ?, ?,?, ?, ?)");
stmt.setInt(1, id);
stmt.setInt(2, type);
stmt.setInt(3, eventGroupID);
stmt.setInt(4, size);
stmt.setString(5, faculty);
stmt.setString(6, course);
stmt.setString(7, grouping);
stmt.setInt(8, eventDuration);
stmt.setDouble(9, wlu);
stmt.executeUpdate();
}
}
catch (Exception e) {
e.printStackTrace();
}
}
private void loadPreferenceList() {
int counter;
Ranking rankChild;
for(Faculty child : utility.getFaculty().values()){
// sort lec
counter = 1;
for(Course courseChild : child.getCourses()){
if (courseChild!=null){
rankChild = new Ranking(child.getId(), counter);
lecPreferenceList.get(courseChild.getId()).getRankList().add(rankChild);
lecPreferenceList.get(courseChild.getId()).sortRank();
counter++;
}
}
// sort tut
counter = 1;
for(Course courseChild : child.getTutCourses()){
if (courseChild!=null){
rankChild = new Ranking(child.getId(), counter);
tutPreferenceList.get(courseChild.getId()).getRankList().add(rankChild);
tutPreferenceList.get(courseChild.getId()).sortRank();
counter++;
}
}
// sort lab
counter = 1;
for(Course courseChild : child.getCourses()){
if (courseChild!=null){
rankChild = new Ranking(child.getId(), counter);
labPreferenceList.get(courseChild.getId()).getRankList().add(rankChild);
labPreferenceList.get(courseChild.getId()).sortRank();
counter++;
}
}
}
}
private void loadVenues(Statement myStmt) {
//execute sql query
try {
ResultSet myRs = myStmt.executeQuery("select * from Venues");
//results set
while (myRs.next()) {
String name = myRs.getString("room_name");
int cap = myRs.getInt(2);
int typeNo = myRs.getInt(3);
Event.Type type = Event.setType(typeNo);
Venue child = new Venue(name, cap, type);
utility.addVenues(child);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public void loadEvents() {
try{
//connection to database
Class.forName("com.mysql.jdbc.Driver");
Connection myConn;
myConn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:8889/fypSchedulingBig", "root", "root");
//create statement
Statement myStmt = (Statement) myConn.createStatement();
ResultSet myRs = myStmt.executeQuery("select * from Event");
utility.getEvents().clear();
while (myRs.next()) {
int id = myRs.getInt(1);
int typeNo = myRs.getInt(2);
Event.Type type = Event.setType(typeNo);
int eventGroupID = myRs.getInt(3);
int size = myRs.getInt(4);
ArrayList<Faculty> facList = new ArrayList<Faculty>();
String list = myRs.getString("faculty");
String[] facIDList = list.split(";");
for(String facName : facIDList){
Faculty fac = facNameList.get(facName);
facList.add(fac);
}
String courseNum = myRs.getString("course");
Course course = courseNumList.get(courseNum);
String groupNum = myRs.getString("grouping");
Grouping grouping = groupingList.get(groupNum);
int eventDuration = myRs.getInt(8);
double wlu = myRs.getInt(9);
Event e = new Event(id, type, eventGroupID, size, facList, course, grouping, eventDuration, wlu);
utility.addEvent(e);
}
// Reset Faculty Assignment info and recalculate WLU allocated
updateWLUAssignedCourse(utility.getEvents().values());
}
catch (Exception e) {
e.printStackTrace();
}
}
private void loadGrouping(Statement myStmt) {
// TODO Auto-generated method stub
try{
ResultSet myRs = myStmt.executeQuery("select * from Grouping");
while (myRs.next()) {
String name = myRs.getString("group_name");
int size = myRs.getInt(2);
int year = myRs.getInt(4);
int specialisation = myRs.getInt(5);
Grouping child = new Grouping(name, size, year,specialisation);
// Tokeniser here to add courses
String[] courseList = myRs.getString("courses_num").split(";");
for(String courseNum : courseList){
Course temp = courseNumList.get(courseNum);
child.addCourse(temp);
}
utility.addGrouping(child);
groupingList.put(child.getGroupName(), child);
}
}
catch (SQLException e) {
e.printStackTrace();
}
}
private void loadFaculty(Statement myStmt) {
//execute sql query
try{
ResultSet myRs = myStmt.executeQuery("select * from Faculty");
//results set
while (myRs.next()) {
Faculty child;
String name = myRs.getString("name");
int appt = myRs.getInt(5);
int adminAppt = myRs.getInt(6);
int serviceHr = myRs.getInt(7);
child = new Faculty(name, appt,adminAppt, serviceHr);
// Tokeniser here to add LEC courses taught
String list = myRs.getString("courses_num");
String[] courseList = list.split(";");
for(String courseNum : courseList){
Course temp = courseNumList.get(courseNum);
child.addCourse(temp);
}
// Tokeniser here to add TUT courses taught
String list2 = myRs.getString("tut_course");
String[] courseList2 = list2.split(";");
for(String courseNum : courseList2){
Course temp = courseNumList.get(courseNum);
child.addTutCourse(temp);
}
// Tokeniser here to add LAB courses taught
String list3 = myRs.getString("lab_course");
String[] courseList3 = list3.split(";");
for(String courseNum : courseList3){
Course temp = courseNumList.get(courseNum);
child.addLabCourse(temp);
}
utility.addFaculty(child);
facNameList.put(child.getName(), child);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
private void loadCourse(Statement myStmt) {
//execute sql query
try {
ResultSet myRs = myStmt.executeQuery("select * from Courses");
//results set
while (myRs.next()) {
Course child;
String courseNum = myRs.getString("course_num");
String courseName = myRs.getString("course_name");
int noOfLecs = myRs.getInt(3);
int noOfTuts = myRs.getInt(4);
int noOfLabs= myRs.getInt(5);
child = new Course(courseNum, courseName, noOfLecs, noOfTuts, noOfLabs);
courseNumList.put(courseNum, child);
utility.addCourses(child);
Preference newLecCourse = new Preference(child);
Preference newTutCourse = new Preference(child);
Preference newLabCourse = new Preference(child);
lecPreferenceList.put(child.getId(), newLecCourse);
tutPreferenceList.put(child.getId(), newTutCourse);
labPreferenceList.put(child.getId(), newLabCourse);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
private void loadHistory(Statement myStmt) {
//execute sql query
try {
ResultSet myRs = myStmt.executeQuery("select * from history");
//results set
while (myRs.next()) {
History child;
String courseNum = myRs.getString("course_num");
Course course = courseNumList.get(courseNum);
child = new History(course);
String list = myRs.getString("history");
String[] facIDList = list.split(";");
for(String facName : facIDList){
Faculty fac = facNameList.get(facName);
child.addFac(fac);
}
utility.addHistory(child);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
/*
* SA Algo
*/
public void runSAAlgo(String approach){
GUI.textbox.setText("Temperature: " + temperature + "\tAlpha: " + alpha);
GUI.textbox.append("\nRunning Stimulated Algorithm. Pls wait...");
bestSolution = new SAPopulation(baseSolution.getList());
// Get Worst WLU from baseSolution
double baseWorstWLU = utility.getWorstWLUAllocated();
double optimalWorstWLU = baseWorstWLU;
int counter = 0;
while(temperature > 1){
SAPopulation proposed = new SAPopulation(baseSolution.getList());
//SWAP
if (approach == "Random") {
// Random Approach
int rand = (int) Math.round( Math.random() );
if (rand == 0)
proposed.populateNewSolution(utility, lecPreferenceList, tutPreferenceList, labPreferenceList);
else
proposed.populateNewGreedySolution2(utility, lecPreferenceList, tutPreferenceList, labPreferenceList);
}else if (approach == "Greedy"){
// Greedy Approach
proposed.populateNewGreedySolution(utility, lecPreferenceList, tutPreferenceList, labPreferenceList);
}else {
// Random Greedy Approach
proposed.populateNewGreedySolution2(utility, lecPreferenceList, tutPreferenceList, labPreferenceList);
}
// Reset Faculty Assignment info and recalculate WLU allocated
updateWLUAssignedCourse(proposed.getList());
// Get Worst WLU from proposeSolution
double newWorstWLU = utility.getWorstWLUAllocated();
solutionTable.add((int)newWorstWLU);
System.out.println(counter + "\tBase: " + baseWorstWLU + "\t\tProposed: " + newWorstWLU + "\t\tOptimal: " + optimalWorstWLU);
String str = counter + "\tBase: " + baseWorstWLU + "\t\tProposed: " + newWorstWLU + "\t\tOptimal: " + optimalWorstWLU;
GUI.appendMessage(str);
//System.out.println(counter + "\tBase: " + base + "\t\tProposed: " + proposedSol + "\t\tOptimal: " + best);
//ACCEPTANCE POLICY
double randGen = randomDouble();
if (acceptPolicy(baseWorstWLU, newWorstWLU, temperature) > randGen) {
baseWorstWLU = newWorstWLU;
baseSolution = new SAPopulation(proposed.getList());
}
// IF PROPOSED SOLUTION IS BETTER, STORE IT
if(baseWorstWLU < optimalWorstWLU ) {
bestSolution = new SAPopulation(baseSolution.getList());
updateWLUAssignedCourse(proposed.getList());
optimalWorstWLU = utility.getWorstWLUAllocated();
}
//COOLING
temperature *=alpha;
counter++;
}
// display output
displayFinalAllocation();
for (Faculty child : utility.getFaculty().values()) {
wluVariationTable.add(child.getWLUVariation(utility.getAvgWLU()));
}
System.out.println(approach);
writeData();
}
private void updateWLUAssignedCourse(LinkedList<Event> target){
for (Faculty child : utility.getFaculty().values()){
// reset WLU Allocated to each fac memeber @utitlity
child.resetWLUAllocated();
// reset courses assigned to each fac memeber @utitlity
child.resetAssignedContained();
}
// Compute the amount of assigned course to each faculty
for (Event child : target){
int courseID = child.getCourse().getId();
Course course = child.getCourse();
for(Faculty facChild : child.getFaculty()){
int facID = facChild.getId();
if (utility.getFaculty().get(facID).assignedContained(courseID)){
utility.getFaculty().get(facID).getAssignedCourse().add(course);
}
}
}
// recalculate events with novelity factor in
for(Event child : target) {
String key = child.getCourse().getCourseNum();
ArrayList<Faculty> facList = child.getFaculty();
double novelity = 1;
if (!utility.getHistory().containsKey(key)){
novelity = 2;
child.calculateWLU(novelity);
}else {
History history = utility.getHistory().get(key);
novelity = history.findFac(facList);
}
child.calculateWLU(novelity);
}
// assign wlu to fac
for (Event child : target){
double wlu;
if (child.getFaculty().size() > 1){
wlu = child.getWLU() / child.getFaculty().size();
}
else{
wlu = child.getWLU();
}
// Update Faculty WLU Allocated
for (Faculty facChild : child.getFaculty()){
utility.getFaculty().get(facChild.getId()).addWLU(wlu);
}
}
}
private void updateWLUAssignedCourse(Collection<Event> values) {
for (Faculty child : utility.getFaculty().values()){
// reset WLU Allocated to each fac memeber @utitlity
child.resetWLUAllocated();
// reset courses assigned to each fac memeber @utitlity
child.resetAssignedContained();
}
// Compute the amount of assigned course to each faculty
for (Event child : values){
int courseID = child.getCourse().getId();
Course course = child.getCourse();
for(Faculty facChild : child.getFaculty()){
int facID = facChild.getId();
if (utility.getFaculty().get(facID).assignedContained(courseID)){
utility.getFaculty().get(facID).getAssignedCourse().add(course);
}
}
}
// recalculate events with novelity factor in
for(Event child : values) {
String key = child.getCourse().getCourseNum();
ArrayList<Faculty> facList = child.getFaculty();
double novelity = 1;
if (!utility.getHistory().containsKey(key)){
novelity = 2;
child.calculateWLU(novelity);
}else {
History history = utility.getHistory().get(key);
novelity = history.findFac(facList);
}
child.calculateWLU(novelity);
}
// assign wlu to fac
for (Event child : values){
double wlu;
if (child.getFaculty().size() > 1){
wlu = child.getWLU() / child.getFaculty().size();
}
else{
wlu = child.getWLU();
}
// Update Faculty WLU Allocated
for (Faculty facChild : child.getFaculty()){
utility.getFaculty().get(facChild.getId()).addWLU(wlu);
}
}
}
private double randomDouble(){
Random r = new Random();
return r.nextInt(1000) / 1000;
}
private double acceptPolicy(double base, double proposed, double temperature){
if (proposed == base) {
return Math.exp((0.1)/ temperature);
}
else if (proposed > base)
// if base is lower than proposed, adjust p
return Math.exp((base-proposed)/ temperature);
else
// accept new result if base is higher than proposed
return 1;
}
public void setAlpha(double alpha) {
this.alpha = alpha;
}
public void setTemperture(double temp) {
this.temperature = temp;
}
public void printSetupConfig(){
System.out.println("\nVENUE DATA");
Map<Integer, Venue> venueList = utility.getVenues();
for(int key : venueList.keySet()){
System.out.println(utility.getVenues().get(key).toString());
}
System.out.println("\nCOURSE DATA");
Map<Integer, Course> courseList = utility.getCourses();
for(int key : courseList.keySet()){
System.out.println(utility.getCourses().get(key).toString());
}
System.out.println("\nFACULTY DATA");
Map<Integer, Faculty> facList = utility.getFaculty();
for(int key : facList.keySet()){
System.out.println(utility.getFaculty().get(key).toString());
}
System.out.println("\nGROUPING DATA");
Map<Integer, Grouping> groupList = utility.getGrouping();
for(int key : groupList.keySet()){
System.out.println(utility.getGrouping().get(key).toString());
}
System.out.println("\nEvent Data");
for (Event child : baseSolution.getList()) {
System.out.println(child.toString());
}
System.out.println("Setup Completed!\n");
}
private void displayFinalAllocation() {
System.out.println("\n\nEvent Allocation Result");
updateWLUAssignedCourse(bestSolution.getList());
utility.getEvents().clear();
for (Event child : bestSolution.getList()) {
System.out.println(child.toString());
utility.getEvents().put(child.getId(), child);
}
System.out.println("\n\nFaculty Assignment Result");
for (Faculty child: utility.getFaculty().values()) {
System.out.println(child.toString2(utility.getAvgWLU()));
}
System.out.println("Worst WLU: " + utility.getWorstWLUAllocated());
String result = "\nEvent Allocation Result";
result += "Worst WLU: " + utility.getWorstWLUAllocated() + "\nFaculty Assignment Result\n";
for (Faculty child: utility.getFaculty().values()) {
result += child.toString2(utility.getAvgWLU()) + "\n";
}
result+= "\n\nEvent Allocation Result\n";
for (Event child : bestSolution.getList()) {
result += child.toString() + "\n";
}
result+= "\nOverloadedFac: " + utility.getOverloadedFac();
GUI.textbox.append(result);
}
public String printCourses() {
String result = "COURSE DATA\n";
Map<Integer, Course> courseList = utility.getCourses();
for(int key : courseList.keySet()){
result += utility.getCourses().get(key).toString() +"\n";
}
return result;
}
public String printFacultyPreference() {
String result = "FACULTY DATA\n";
Map<Integer, Faculty> facList = utility.getFaculty();
for(int key : facList.keySet()){
result += utility.getFaculty().get(key).toString() + "\n";
}
return result;
}
public String printFaculty() {
String result = "FACULTY DATA\n";
Map<Integer, Faculty> facList = utility.getFaculty();
for(int key : facList.keySet()){
result += utility.getFaculty().get(key).toString3(utility.getAvgWLU()) + "\n";
}
double worstWLU = utility.getWorstWLUAllocated();
double avgWLU = utility.getAvgWLU();
result += "\n\nAvg WLU: " + avgWLU + "\tWLU Fitness: " + worstWLU;
return result;
}
public String printGrouping() {
String result = "GROUPING DATA\n";
Map<Integer, Grouping> groupList = utility.getGrouping();
for(int key : groupList.keySet()){
result+=utility.getGrouping().get(key).toString() + "\n";
}
return result;
}
public String printVenues() {
String result = "VENUES DATA\n";
Map<Integer, Venue> venueList = utility.getVenues();
for(int key : venueList.keySet()){
result += utility.getVenues().get(key).toString() + "\n";
}
return result;
}
public String printHistory() {
String result = "HISTORIC DATA\n";
Map<String, History> historyList = utility.getHistory();
for(String key : historyList.keySet()){
result += utility.getHistory().get(key).toString() + "\n";
}
return result;
}
public String printEvents() {
String result = "EVENTS DATA\n";
Map<Integer, Event> eventList = utility.getEvents();
for(int key : eventList.keySet()){
result += utility.getEvents().get(key).toString() + "\n";
}
return result;
}
private static void writeData() {
// TODO Auto-generated method stub
FileWriter writer;
try {
writer = new FileWriter("output.txt");
for(int i =0; i < solutionTable.size(); i++){
String str = "" + solutionTable.get(i) +"\n";
writer.write(str);
}
writer.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
writer = new FileWriter("wluVariation.txt");
for(int i =0; i < wluVariationTable.size(); i++){
String str = "" + wluVariationTable.get(i) +"\n";
writer.write(str);
}
writer.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}