# load_flattening > Solve the load flattening V2G problem --- ## Description load_flattening solves the load flattening optimization problem under a given scenario using either a centralized or distributed algorithm. ## Syntax ```matlab [cost,u,lam,result_option] = load_flattening(scenario,algorithm_type) [cost,u,lam,result_option] = load_flattening(scenario,algorithm_type,Name=Value) ``` ## Input Arguments | Name | Type | Description | |------|------|--------------| | `scenario` | *Scenario object* | Scenario object that specifies the optimization problem | | `algorithm_type` | *"cent" \| "dist"* | Type of algorithm, either "cent" for centralized or "dist" for distributed algorithm | ## Name-Value Arguments | Name | Type | Description | |------|------|--------------| | `rho` | *5000 (default) \| nonnegative scalar* | Penalty parameter | | `Lf_kP` | *1 (default) \| positive scalar* | Coupling gain (proportional) for distributed PI algorithm (Only for "dist") | | `Lf_kI` | *1 (default) \| positive scalar* | Coupling gain (integral) for distributed PI algorithm (Only for "dist") | | `Lf_time` | *400 (default) \| positive scalar* | Length of time interval on which PI dynamics is executed (Only for "dist") | | `Lf_dt` | *0.0005 (default) \| positive scalar* | Stepsize for the Euler discritization of PI dynamics (Only for "dist") | | `Lf_scale` | *0.05 (default) \| positive scalar* | Cost function scaling factor for PI dynamics (Only for "dist") | | `quiet` | *false (default) \| logical* | On/off solver messages | ## Output Arguments | Name | Type | Description | |------|------|--------------| | `cost` | *scalar* | Optimal cost | | `u` | *T×N_c matrix* | Optimal charging/discharging schedule | | `lam` | *T×1 vector* | Lagrange multiplier for balance constraint | | `result_option` | *struct* | Specification of the options used for solver |