Commit c9f00073 authored by Jonathan Shahen's avatar Jonathan Shahen

Done adding the roleSchedule to the Uzun straight conversion - still requires...

Done adding the roleSchedule to the Uzun straight conversion - still requires testing (add test to the RegressionTests), but that will be done in the morning
parent 4b05d804
......@@ -7,12 +7,14 @@ import mohawk.converter.pieces.TimeInterval;
public class TimeIntervalHelper {
public SortedSet<TimeInterval> _timeslots = new TreeSet<TimeInterval>();
public Integer maxTimeSlot = 0;
public Integer maxTimeSlot = -1;
public Integer minTimeSlot = -1;
public void add(TimeInterval ti) {
_timeslots.add(ti);
maxTimeSlot = Math.max(maxTimeSlot, ti._finish + 1);
maxTimeSlot = Math.max(maxTimeSlot, ti._finish);
minTimeSlot = Math.min(minTimeSlot, ti._start);
}
/**
......@@ -20,8 +22,9 @@ public class TimeIntervalHelper {
*
* @return the greatest timeslot that is valid
*/
public Integer getMaxTimeSlotSeen() {
return maxTimeSlot - 1;
public Integer getNumberOfTimeSlots() {
if (maxTimeSlot == -1) { return -1; }
return maxTimeSlot - minTimeSlot + 1; // if maxTimeSlot == minTimeSlot => returns 1
}
/**
......@@ -29,8 +32,8 @@ public class TimeIntervalHelper {
*
* @return the greatest timeslot that is valid and hasn't been used
*/
public Integer getNextTimeslot() {
return maxTimeSlot;
public Integer getNextTimeSlot() {
return maxTimeSlot + 1;
}
public Integer size() {
......
......@@ -9,6 +9,7 @@ public class UzunRule {
public Integer finishTime;
public Integer role;
public Integer[] precondition;
public Integer[] roleSchedule;
public UzunRule(Rule r, RoleHelper rh, TimeIntervalHelper tih) {
ruleType = r._type.toUzun();
......@@ -34,5 +35,14 @@ public class UzunRule {
precondition[i] = 0;
}
}
roleSchedule = new Integer[tih.getNextTimeSlot()];
for (Integer i = 0; i < roleSchedule.length; i++) {
if (r._roleSchedule.contains(i)) {
roleSchedule[i] = 1;
} else {
roleSchedule[i] = 0;
}
}
}
}
......@@ -64,7 +64,7 @@ public class RegressionTests {
// t0, t1, t2, t5
assertEquals("Incorrect number of Timeslots", new Integer(4), parser.timeIntervalHelper.size());
// t0, t1, t2, t5
assertEquals("Incorrect max Timeslot", new Integer(5), parser.timeIntervalHelper.getMaxTimeSlotSeen());
assertEquals("Incorrect max Timeslot", new Integer(5), parser.timeIntervalHelper.getNumberOfTimeSlots());
}
@Test
......@@ -89,7 +89,7 @@ public class RegressionTests {
// t0, t1, t2, t5
assertEquals("Incorrect number of Timeslots", new Integer(4), parser.timeIntervalHelper.size());
// t0, t1, t2, t5
assertEquals("Incorrect max Timeslot", new Integer(5), parser.timeIntervalHelper.getMaxTimeSlotSeen());
assertEquals("Incorrect max Timeslot", new Integer(5), parser.timeIntervalHelper.getNumberOfTimeSlots());
}
@Test
......@@ -114,7 +114,7 @@ public class RegressionTests {
// t0, t1, t2, t5
assertEquals("Incorrect number of Timeslots", new Integer(4), parser.timeIntervalHelper.size());
// t0, t1, t2, t5
assertEquals("Incorrect max Timeslot", new Integer(5), parser.timeIntervalHelper.getMaxTimeSlotSeen());
assertEquals("Incorrect max Timeslot", new Integer(5), parser.timeIntervalHelper.getNumberOfTimeSlots());
}
@Test
......
......@@ -24,7 +24,7 @@ public class ConvertToUzun implements ConvertTo {
Charset.defaultCharset());
ST st = new ST(template);
st.add("numRoles", p.roleHelper.size());
st.add("numTimeSlots", p.timeIntervalHelper.getNextTimeslot());
st.add("numTimeSlots", p.timeIntervalHelper.getNextTimeSlot());
st.add("goalStates", p.query.toUzun(p.roleHelper));
for (Rule r : p.canAssign.getRules()) {
......
<numRoles> <numTimeSlots><! Conversion to Uzun's Input Format !>
<goalStates; separator=" "><! Goal States {0,1} * numRoles !>
<rules:{r|<r.ruleType> <r.startTime> <r.finishTime> <r.role><\n><\t><r.precondition; separator=" "><\n>}><! RuleType StartTime FinsihTime RoleToGive !>
\ No newline at end of file
<rules:{r|<r.ruleType> <r.startTime> <r.finishTime> <r.role><\n><\t><r.precondition; separator=" "><\n><\t><r.roleSchedule; separator=" "><\n>}><! RuleType StartTime FinsihTime RoleToGive !>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment