Skip to content

Commit

Permalink
norm subgroups to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Jun 27, 2024
1 parent 0ec23f8 commit 5991135
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private void runCommand(Class<? extends MATSimAppCommand> clazz, Path input) thr
MATSimAppCommand command = clazz.getDeclaredConstructor().newInstance();
String[] args = this.args.get(clazz);
args = ArrayUtils.addAll(args, createArgs(clazz, args, input));
log.info("Running {} with arguments: {}", clazz, Arrays.toString(args));
log.info("Running {} with arguments: {}", clazz, String.join(" ", args));

command.execute(args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ final class TripByGroupAnalysis {
}
}

// Norm shares per instance of each group to sum of 1
for (Group group : this.groups) {

String norm = group.columns.get(0);
if (group.columns.size() > 1)
throw new UnsupportedOperationException("Multiple columns not supported yet");

Table df = group.data;
for (String label : df.stringColumn(norm).asSet()) {
DoubleColumn dist_group = df.doubleColumn("share");
Selection sel = df.stringColumn(norm).isEqualTo(label);
double total = dist_group.where(sel).sum();
if (total > 0)
dist_group.set(sel, dist_group.divide(total));
}
}
}
}

Expand Down

0 comments on commit 5991135

Please sign in to comment.