Skip to content

Commit

Permalink
extract more reference groups
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Jun 11, 2024
1 parent 5f42386 commit 6ea1372
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,34 @@
public final class AdvancedScoringConfigGroup extends ReflectiveConfigGroup {

private static final String GROUP_NAME = "advancedScoring";

private final List<ScoringParameters> scoringParameters = new ArrayList<>();

/**
* Different options for income dependent scoring.
*/
public enum IncomeDependentScoring {
none,
avg_by_personal_income
}

@Parameter
@Comment("The distance groups if marginal utility of distance is adjusted. In meters.")
public List<Integer> distGroups;

@Parameter
@Comment("Enable income dependent marginal utility of money.")
public IncomeDependentScoring incomeDependent = IncomeDependentScoring.avg_by_personal_income;

public IncomeDependentScoring incomeDependent = IncomeDependentScoring.avgByPersonalIncome;

// TODO: maybe option to re-assign variations or use them from attributes
// TODO: could load the random variations from a file, helper function to only generate the variations
@Parameter
@Comment("Define how to load existing preferences.")
public LoadPreferences loadPreferences = LoadPreferences.none;

public AdvancedScoringConfigGroup() {
super(GROUP_NAME);
}

/**
* Return the defined scoring parameters.
* Return the defined scoring parameters.
*/
public List<ScoringParameters> getScoringParameters() {
return Collections.unmodifiableList(scoringParameters);
}

// TODO: maybe option to re-assign variations or use them from attributes
// TODO: could load the random variations from a file, helper function to only generate the variations

@Override
public ConfigGroup createParameterSet(String type) {
if (type.equals(ScoringParameters.GROUP_NAME)) {
Expand All @@ -66,6 +60,30 @@ public void addParameterSet(ConfigGroup set) {
}
}

/**
* Different options for income dependent scoring.
*/
public enum IncomeDependentScoring {
none,
avgByPersonalIncome
}

/**
* Define how existing preferences are loaded.
*/
public enum LoadPreferences {
none,
requireAttribute,
skipRefPersons
}

/**
* Variate values with random draw from specific distribution.
*/
public enum VariationType {
fixed, normal, truncatedNormal
}

/**
* Scoring parameters for a specific group of agents.
* This group allows arbitrary attributes to be defined, which are matched against person attributes.
Expand Down Expand Up @@ -175,11 +193,4 @@ public ModeParams() {
super(GROUP_NAME);
}
}

/**
* Variate values with random draw from specific distribution.
*/
public enum VariationType {
fixed, normal, truncatedNormal
}
}
5 changes: 3 additions & 2 deletions src/main/python/extract_ref_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ def person_filter(df):
df = df[df.reporting_day <= 4]
df = df[df.location == "Berlin"]

df["age"] = preparation.cut(df.age, [0, 18, 66, np.inf])
df["age"] = preparation.cut(df.age, [0, 12, 18, 25, 35, 66, np.inf])

preparation.fill(df, "economic_status", EconomicStatus.UNKNOWN)
preparation.fill(df, "income", -1)

return df

Expand All @@ -35,7 +36,7 @@ def trip_filter(df):
d + "Berlin+Umland",
person_filter, trip_filter,
run_create_ref_data.InvalidHandling.REMOVE_TRIPS,
ref_groups=["age", "economic_status"]
ref_groups=["age", "income", "economic_status", "employment", "car_avail", "bike_avail", "pt_abo_avail"]
)

print(result.share)
Expand Down

0 comments on commit 6ea1372

Please sign in to comment.