Skip to content

Commit

Permalink
conf scheduling: define all hard constraint names and explain in xlsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0ffrey committed Jan 30, 2018
1 parent a8b2a32 commit 6a0ed25
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 136 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Expand Up @@ -20,6 +20,20 @@

public class ConferenceParametrization extends AbstractPersistable {

public static final String TALK_TYPE_OF_TIMESLOT = "Talk type of timeslot";
public static final String ROOM_UNAVAILABLE_TIMESLOT = "Room unavailable timeslot";
public static final String ROOM_CONFLICT = "Room conflict";
public static final String SPEAKER_UNAVAILABLE_TIMESLOT = "Speaker unavailable timeslot";
public static final String SPEAKER_CONFLICT = "Speaker conflict";
public static final String SPEAKER_REQUIRED_TIMESLOT_TAG = "Speaker required timeslot tag";
public static final String SPEAKER_PROHIBITED_TIMESLOT_TAG = "Speaker prohibited timeslot tag";
public static final String TALK_REQUIRED_TIMESLOT_TAG = "Talk required timeslot tag";
public static final String TALK_PROHIBITED_TIMESLOT_TAG = "Talk prohibited timeslot tag";
public static final String SPEAKER_REQUIRED_ROOM_TAG = "Speaker required room tag";
public static final String SPEAKER_PROHIBITED_ROOM_TAG = "Speaker prohibited room tag";
public static final String TALK_REQUIRED_ROOM_TAG = "Talk required room tag";
public static final String TALK_PROHIBITED_ROOM_TAG = "Talk prohibited room tag";

public static final String THEME_TRACK_CONFLICT = "Theme track conflict";
public static final String SECTOR_CONFLICT = "Sector conflict";
public static final String CONTENT_AUDIENCE_LEVEL_FLOW_VIOLATION = "Content audience level flow violation";
Expand Down
Expand Up @@ -188,18 +188,28 @@ private void readConfiguration() {
"Soft penalty per missing preferred tag in a talk's room");
readConstraintLine(TALK_UNDESIRED_ROOM_TAG, parametrization::setTalkUndesiredRoomTag,
"Soft penalty per undesired tag in a talk's room");
// TODO Read hard constraints too, not done for now for backwards compatibility of xlsx file
solution.setParametrization(parametrization);
}

private void readConstraintLine(String name, Consumer<Integer> consumer, String constraintdescription) {
nextRow();
readHeaderCell(name);
double value = nextCell().getNumericCellValue();
if (((double) ((int) value)) != value) {
throw new IllegalArgumentException(currentPosition() + ": The value (" + value
+ ") for constraint (" + name + ") must be an integer.");
XSSFCell weightCell = nextCell();
if (consumer != null) {
double value = weightCell.getNumericCellValue();
if (((double) ((int) value)) != value) {
throw new IllegalArgumentException(currentPosition() + ": The value (" + value
+ ") for constraint (" + name + ") must be an integer.");
}
consumer.accept((int) value);
} else {
if (!weightCell.getStringCellValue().equals("n/a")) {
throw new IllegalArgumentException(currentPosition() + ": The value ("
+ weightCell.getStringCellValue()
+ ") for constraint (" + name + ") must be an n/a.");
}
}
consumer.accept((int) value);
readHeaderCell(constraintdescription);
}

Expand Down Expand Up @@ -777,13 +787,45 @@ private void writeConfiguration() {
"Soft penalty per missing preferred tag in a talk's room");
writeConstraintLine(TALK_UNDESIRED_ROOM_TAG, parametrization::getTalkUndesiredRoomTag,
"Soft penalty per undesired tag in a talk's room");
nextRow();
writeConstraintLine(TALK_TYPE_OF_TIMESLOT, null,
"Hard penalty per talk in a timeslot with an other talk type");
writeConstraintLine(ROOM_UNAVAILABLE_TIMESLOT, null,
"Hard penalty per talk with an unavailable room at its timeslot");
writeConstraintLine(ROOM_CONFLICT, null,
"Hard penalty per pair of talks in the same room in overlapping timeslots");
writeConstraintLine(SPEAKER_UNAVAILABLE_TIMESLOT, null,
"Hard penalty per talk with an unavailable speaker at its timeslot");
writeConstraintLine(SPEAKER_CONFLICT, null,
"Hard penalty per pair of talks with the same speaker in overlapping timeslots");
writeConstraintLine(SPEAKER_REQUIRED_TIMESLOT_TAG, null,
"Hard penalty per missing required tag in a talk's timeslot");
writeConstraintLine(SPEAKER_PROHIBITED_TIMESLOT_TAG, null,
"Hard penalty per prohibited tag in a talk's timeslot");
writeConstraintLine(TALK_REQUIRED_TIMESLOT_TAG, null,
"Hard penalty per missing required tag in a talk's timeslot");
writeConstraintLine(TALK_PROHIBITED_TIMESLOT_TAG, null,
"Hard penalty per prohibited tag in a talk's timeslot");
writeConstraintLine(SPEAKER_REQUIRED_ROOM_TAG, null,
"Hard penalty per missing required tag in a talk's room");
writeConstraintLine(SPEAKER_PROHIBITED_ROOM_TAG, null,
"Hard penalty per prohibited tag in a talk's room");
writeConstraintLine(TALK_REQUIRED_ROOM_TAG, null,
"Hard penalty per missing required tag in a talk's room");
writeConstraintLine(TALK_PROHIBITED_ROOM_TAG, null,
"Hard penalty per prohibited tag in a talk's room");
autoSizeColumnsWithHeader();
}

private void writeConstraintLine(String name, Supplier<Integer> supplier, String constraintdescription) {
nextRow();
nextHeaderCell(name);
nextCell().setCellValue(supplier.get());
XSSFCell weightCell = nextCell();
if (supplier != null) {
weightCell.setCellValue(supplier.get());
} else {
weightCell.setCellValue("n/a");
}
nextHeaderCell(constraintdescription);
}

Expand Down
Expand Up @@ -38,7 +38,7 @@ rule "Talk type of timeslot"
scoreHolder.addHardConstraintMatch(kcontext, -100);
end

rule "Room unavailable timeslots"
rule "Room unavailable timeslot"
when
Talk(hasUnavailableRoom())
then
Expand All @@ -57,7 +57,7 @@ rule "Room conflict"
scoreHolder.addHardConstraintMatch(kcontext, -10);
end

rule "Speaker unavailable timeslots"
rule "Speaker unavailable timeslot"
when
Talk(hasAnyUnavailableSpeaker())
then
Expand All @@ -84,16 +84,16 @@ rule "Speaker required timeslot tag"
scoreHolder.addHardConstraintMatch(kcontext, - $count);
end

rule "Talk required timeslot tag"
rule "Speaker prohibited timeslot tag"
when
Talk($count : missingRequiredTimeslotTagCount() > 0)
Talk($count : prevailingSpeakerProhibitedTimeslotTagCount() > 0)
then
scoreHolder.addHardConstraintMatch(kcontext, - $count);
end

rule "Speaker prohibited timeslot tag"
rule "Talk required timeslot tag"
when
Talk($count : prevailingSpeakerProhibitedTimeslotTagCount() > 0)
Talk($count : missingRequiredTimeslotTagCount() > 0)
then
scoreHolder.addHardConstraintMatch(kcontext, - $count);
end
Expand All @@ -112,16 +112,16 @@ rule "Speaker required room tag"
scoreHolder.addHardConstraintMatch(kcontext, - $count);
end

rule "Talk required room tag"
rule "Speaker prohibited room tag"
when
Talk($count : missingRequiredRoomTagCount() > 0)
Talk($count : prevailingSpeakerProhibitedRoomTagCount() > 0)
then
scoreHolder.addHardConstraintMatch(kcontext, - $count);
end

rule "Speaker prohibited room tag"
rule "Talk required room tag"
when
Talk($count : prevailingSpeakerProhibitedRoomTagCount() > 0)
Talk($count : missingRequiredRoomTagCount() > 0)
then
scoreHolder.addHardConstraintMatch(kcontext, - $count);
end
Expand Down

0 comments on commit 6a0ed25

Please sign in to comment.