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

21 update shifts per year definition #22

Merged
merged 3 commits into from
Oct 7, 2024
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
17 changes: 11 additions & 6 deletions docs/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ python sweep.py --help

```
$ python sweep.py --help
usage: SWEEP [-h] [--config CONFIG] [--analysis-id ANALYSIS_ID] [--vehicles VEHICLES] [--scenarios SCENARIOS] [--selections [SELECTIONS ...]] [--eng-curves ENG_CURVES] [--lw-curves LW_CURVES] [--aero-curves AERO_CURVES] [--look-for LOOK_FOR] [--skip-all-opt] [--skip-input-validation] [--exclude [EXCLUDE ...]] [--algorithms [ALGORITHMS ...]] [--dst-dir DST_DIR] [--dir-mark DIR_MARK] [--file-mark FILE_MARK] [--skip-save-veh] [--x-tol X_TOL] [--f-tol F_TOL] [--n-max-gen N_MAX_GEN] [--pop-size POP_SIZE] [--nth-gen NTH_GEN] [--n-last N_LAST]
[--range-overshoot-tol RANGE_OVERSHOOT_TOL] [---missed-trace-correction] [--max-time-dilation MAX_TIME_DILATION] [--min-time-dilation MIN_TIME_DILATION] [--time-dilation-tol TIME_DILATION_TOL] [--write-tsv WRITE_TSV]
usage: SWEEP [-h] [--config CONFIG] [--analysis-id ANALYSIS_ID] [--vehicles VEHICLES] [--scenarios SCENARIOS] [--selections [SELECTIONS ...]] [--eng-curves ENG_CURVES] [--lw-curves LW_CURVES]
[--aero-curves AERO_CURVES] [--look-for LOOK_FOR] [--skip-all-opt] [--skip-input-validation] [--exclude [EXCLUDE ...]] [--algorithms [ALGORITHMS ...]] [--dst-dir DST_DIR]
[--dir-mark DIR_MARK] [--file-mark FILE_MARK] [--skip-save-veh] [--x-tol X_TOL] [--f-tol F_TOL] [--n-max-gen N_MAX_GEN] [--pop-size POP_SIZE] [--nth-gen NTH_GEN] [--n-last N_LAST]
[--range-overshoot-tol RANGE_OVERSHOOT_TOL] [---missed-trace-correction] [--max-time-dilation MAX_TIME_DILATION] [--min-time-dilation MIN_TIME_DILATION]
[--time-dilation-tol TIME_DILATION_TOL] [--write-tsv WRITE_TSV]

The sweep.py module is the main script to run T3CO

Expand All @@ -48,7 +51,8 @@ optional arguments:
--scenarios SCENARIOS
Input file for Scenario models (default: ./resources/inputs/demo/Demo_FY22_scenario_assumptions.csv)
--selections [SELECTIONS ...]
Selections desired to run. Selections can be an int, or list of ints, or range expression. Ex: --selections 234 or --selections "[234,236,238]" or --selections "range(234, 150, 2)" (default: None)
Selections desired to run. Selections can be an int, or list of ints, or range expression. Ex: --selections 234 or --selections "[234,236,238]" or --selections "range(234,
150, 2)" (default: None)
--eng-curves ENG_CURVES
Input file for engine efficiency improvement cost curves (default: ./resources/auxiliary/EngineEffImprovementCostCurve.csv)
--lw-curves LW_CURVES
Expand All @@ -63,16 +67,17 @@ optional arguments:
--exclude [EXCLUDE ...]
Overrides -look_for. a string for string matching to exclude runs, example -exclude 'FCEV' or -look_for '["FCEV", "HEV"]' (default: >{-<>-}<)
--algorithms [ALGORITHMS ...], --algos [ALGORITHMS ...], --algo [ALGORITHMS ...]
Enter algorithm or list of algorithms, or "ensemble" to use all, to use for optimization: ['NSGA2', 'NelderMead', 'PatternSearch', 'PSO'] ex: -algos PatternSearch | -algos '["PatternSearch", "NSGA2"]' | -algos "ensemble" (default: NSGA2)
--dst-dir DST_DIR Directory to store T3CO results (default: ../results)
Enter algorithm or list of algorithms, or "ensemble" to use all, to use for optimization: ['NSGA2', 'NelderMead', 'PatternSearch', 'PSO'] ex: -algos PatternSearch | -algos
'["PatternSearch", "NSGA2"]' | -algos "ensemble" (default: NSGA2)
--dst-dir DST_DIR Directory to store T3CO results (default: ./results)
--dir-mark DIR_MARK Name for results directory in addition to timestamp (default: )
--file-mark FILE_MARK
Prefix to add to the result file names (default: )
--skip-save-veh Toggle result vehicle model YAML file saving off (default: False)
--x-tol X_TOL Parameter space tolerance for optimization (default: 0.001)
--f-tol F_TOL Objective space tolerance for optimzation (default: 0.001)
--n-max-gen N_MAX_GEN
Cax number of optimizer iterations regardless of algorithm (default: 1000)
Max number of optimizer iterations regardless of algorithm (default: 1000)
--pop-size POP_SIZE population of each generation (default: 25)
--nth-gen NTH_GEN Period of generations in which to evaluate if convergence happens during optimization (default: 1)
--n-last N_LAST Number of generations to look back for establishing convergence during optimization (default: 5)
Expand Down
2 changes: 1 addition & 1 deletion docs/scenario_inputs_descriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fc_ice_base_cost_dol | Cost of Fuel Convertor
| constraint_grade | Optimization constraint - Gradeability 1.25% grade and 6% grade | bool |
| objective_tco | Boolean switch for minimizing TCO as optimization objective | bool |
| constraint_c_rate | Optimization constraint - Charge Rate | bool |
| shifts_per_year | Number of shifts/drivecycle instances per year traveled by the vehicle as a vector of length equal to number of TCO years. if = 0, then it's calculated from vmt and daily distance | list\[int\] |
| shifts_per_year | Number of shift / drive cycle instances the vehicle travels per year as a vector of length equal to number of TCO years. If not specified, then it's calculated from vmt and drive cycle distance. NOTE: if the drive cycle includes the full duration of a shift, best practice is to leave this blank or 0 or \[0\]; otherwise , i.e. if it is a compressed or regulatory cycle, shifts per year should be specified. | list\[int\] |
| motor_power_override_kw_fc_demand_on_pct | For PHEV, percentage motor power override as fraction | float |
| soc_norm_init_for_accel_pct | Initial normalized SOC for acceleration test (only PHEV) | float |
| soc_norm_init_for_grade_pct | Initial normalized SOC for gradeability test (only PHEV) | float |
Expand Down
8 changes: 5 additions & 3 deletions t3co/run/run_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
from t3co.run import Global as gl
from t3co.tco import tco_analysis

# import importlib
# tco_analysis = importlib.reload(tco_analysis)


# --------------------------------- \\ powertrain adjustment methods --------------------------------- #
Expand Down Expand Up @@ -99,7 +97,6 @@ def from_dict(self, config_dict: dict) -> Self:
Returns:
Self: Config instance containining all values from T3CO Config CSV file
"""
# config_dict['selections'] = np.array(ast.literal_eval(config_dict['selections']))
try:
config_dict["selections"] = ast.literal_eval(config_dict["selections"])
except: # noqa: E722
Expand Down Expand Up @@ -535,6 +532,11 @@ def get_scenario_and_cycle(
scenario = load_scenario(veh_no, scenario_inputs_path, a_vehicle, config)
cyc = load_design_cycle_from_scenario(scenario, gl.OPTIMIZATION_DRIVE_CYCLES)

if isinstance(cyc, list):
scenario.constant_trip_distance_mi = sum([sum(cyc[i][0].mph * np.diff(np.array(cyc[i][0].time_s), append=0))*cyc[i][1]/3600 for i in range(len(cyc))])
else:
scenario.constant_trip_distance_mi = sum(cyc.mph * np.diff(np.array(cyc.time_s), append=0))/3600

return scenario, cyc


Expand Down
4 changes: 1 addition & 3 deletions t3co/sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ def skip_scenario(sel: int, scenario_name: str, verbose: bool = False) -> bool:
"--n-max-gen",
default=1000,
type=float,
help="Cax number of optimizer iterations regardless of algorithm",
help="Max number of optimizer iterations regardless of algorithm",
)
parser.add_argument("--pop-size", default=25, help="population of each generation")
parser.add_argument(
Expand Down Expand Up @@ -1346,9 +1346,7 @@ def skip_scenario(sel: int, scenario_name: str, verbose: bool = False) -> bool:
lw_imp_curves = Path(args.lw_imp_curves)
aero_drag_imp_curves = Path(args.aero_drag_imp_curves)
write_tsv = args.write_tsv
# config = None
else:
# args.analysis_id = ast.literal_eval(args.analysis_id)
try:
config = rs.Config()
config.from_file(filename=args.config, analysis_id=args.analysis_id)
Expand Down
Loading
Loading