Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMC Maintenance + Test Fixes #3653

Merged
merged 5 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,14 @@ public void run(Plan plan) {
for (int i = 0; i < mask.length; i++) {
if (mask[i])
option[i] = m;

options.add(option);
}

options.add(option);
}

List<PlanCandidate> singleModeCandidates = ctx.generator.generatePredefined(model, options);
singleModeCandidates.removeIf(p -> p.getUtility() == Double.NEGATIVE_INFINITY);

// if none of the single mode options are valid, no further search is needed
// this works in conjunction with subtour constraints, with other constraints it might be too strict
if (singleModeCandidates.size() <= 1) {
continue;
}

// Single modes are also added
Set<PlanCandidate> candidateSet = new LinkedHashSet<>(singleModeCandidates);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public List<PlanCandidate> generatePredefined(PlanModel planModel, List<String[]
// reduce to single options that are usable
for (Map.Entry<String, List<ModeEstimate>> e : planModel.getEstimates().entrySet()) {
for (ModeEstimate o : e.getValue()) {
// check if a mode can be use at all
// check if a mode can be used at all
if (!o.isUsable() || o.isMin())
continue;

Expand All @@ -328,6 +328,8 @@ public List<PlanCandidate> generatePredefined(PlanModel planModel, List<String[]

double estimate = 0;

ReferenceSet<String> usedModes = new ReferenceOpenHashSet<>();

// Collect estimates for all entries
for (int i = 0; i < result.length; i++) {

Expand All @@ -351,10 +353,11 @@ public List<PlanCandidate> generatePredefined(PlanModel planModel, List<String[]

estimate += opt.getEstimates()[i];

// Store modes that have been used
if (!opt.getNoRealUsage()[i])
usedModes.add(mode);
}

ReferenceSet<String> usedModes = new ReferenceOpenHashSet<>(result);

estimate += computePlanEstimate(context, planModel, result, usedModes, consolidateModes, singleOptions.values());

for (ConstraintHolder<?> c : constraints) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void replanning() {
double[] selectModes = sampleModes(plans, select);

assertThat(selectModes)
.containsExactly(randomModes, Offset.offset(1200d));
.containsExactly(randomModes, Offset.offset(1700d));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void innovationRates() {

}

assertThat(count.getSum()).isCloseTo(3000 * 600, Offset.offset(300));
assertThat(count.getSum()).isCloseTo(3000 * 600, Offset.offset(2000));
assertThat(count.getDifference()).isLessThanOrEqualTo(2);
}

Expand Down
Loading