import%20marimo%0A%0A__generated_with%20%3D%20%220.23.16%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Clean-equipment%20rebates%20under%20Cobb--Douglas%20production%0A%0A%20%20%20%20A%20regulator%20wants%20a%20producer%20to%20substitute%20clean%20equipment%20for%20a%20fossil%0A%20%20%20%20input%20without%20prescribing%20the%20producer's%20operating%20plan.%20The%20regulator%0A%20%20%20%20therefore%20chooses%20a%20per-unit%20clean-equipment%20rebate%2C%20and%20the%20producer%0A%20%20%20%20responds%20by%20purchasing%20the%20least-cost%20input%20mix%20that%20meets%20a%20fixed%20output%0A%20%20%20%20requirement.%20The%20Cobb--Douglas%20production%20requirement%20is%20represented%20by%20a%0A%20%20%20%20three-dimensional%20power%20cone.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20from%20pathlib%20import%20Path%0A%0A%20%20%20%20import%20cvxpy%20as%20cp%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20from%20scipy.optimize%20import%20minimize_scalar%0A%0A%20%20%20%20from%20blvpy%20import%20BilevelProblem%2C%20LowerProblem%0A%0A%20%20%20%20_style_path%20%3D%20Path(__file__).resolve().parents%5B1%5D%20%2F%20%22_shared%22%20%2F%20%22zhlatex.mplstyle%22%0A%20%20%20%20plt.style.use(_style_path)%0A%20%20%20%20return%20BilevelProblem%2C%20LowerProblem%2C%20cp%2C%20minimize_scalar%2C%20mo%2C%20np%2C%20plt%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Policy%20and%20producer%20problems%0A%0A%20%20%20%20Let%20%24r%24%20be%20the%20clean-equipment%20rebate.%20The%20producer%20chooses%20clean%20and%0A%20%20%20%20fossil%20inputs%20%24(c%2Cf)%24%20and%20pays%20the%20net%20operating%20cost%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%20%20(12-r)c%2B6f.%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20Normalized%20output%20is%20%24c%5E%7B0.35%7Df%5E%7B0.65%7D%24%2C%20so%20the%20producer's%20response%20is%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Cbegin%7Barray%7D%7Bll%7D%0A%20%20%20%20%20%20%20%20S(r)%3D%5Cmathop%7B%5Cmathrm%7Bargmin%7D%7D_%7Bc%2Cf%7D%20%26%20(12-r)c%2B6f%5C%5C%0A%20%20%20%20%20%20%20%20%5Ctext%7Bsubject%20to%7D%20%26%20c%5E%7B0.35%7Df%5E%7B0.65%7D%5Cgeq1.%0A%20%20%20%20%5Cend%7Barray%7D%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20The%20regulator%20targets%20fossil%20use%20of%20%241.15%24%20and%20also%20accounts%20for%20the%0A%20%20%20%20fiscal%20burden%20of%20a%20larger%20posted%20rebate%3A%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Cbegin%7Barray%7D%7Bll%7D%0A%20%20%20%20%20%20%5Cmathop%7B%5Cmathrm%7Bminimize%7D%7D_%7Br%2Cc%2Cf%7D%0A%20%20%20%20%20%20%20%20%26%20(f-1.15)%5E2%2B0.0005r%5E2%20%5C%5C%0A%20%20%20%20%20%20%5Cmathop%7B%5Cmathrm%7Bsubject%5C%20to%7D%7D%0A%20%20%20%20%20%20%20%20%26%200%5Cleq%20r%5Cleq8%2C%5C%5C%0A%20%20%20%20%20%20%20%20%26%20(c%2Cf)%5Cin%20S(r).%0A%20%20%20%20%5Cend%7Barray%7D%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20The%20upper%20bound%20on%20%24r%24%20keeps%20the%20net%20clean-input%20price%20positive.%20Thus%20the%0A%20%20%20%20producer%20has%20a%20unique%20finite%20response%20throughout%20the%20policy%20interval.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20production_elasticity%20%3D%200.35%0A%20%20%20%20clean_list_price%20%3D%2012.0%0A%20%20%20%20fossil_price%20%3D%206.0%0A%20%20%20%20fossil_target%20%3D%201.15%0A%20%20%20%20rebate_penalty%20%3D%200.0005%0A%20%20%20%20rebate_bounds%20%3D%20(0.0%2C%208.0)%0A%20%20%20%20initial_rebate%20%3D%204.0%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20clean_list_price%2C%0A%20%20%20%20%20%20%20%20fossil_price%2C%0A%20%20%20%20%20%20%20%20fossil_target%2C%0A%20%20%20%20%20%20%20%20initial_rebate%2C%0A%20%20%20%20%20%20%20%20production_elasticity%2C%0A%20%20%20%20%20%20%20%20rebate_bounds%2C%0A%20%20%20%20%20%20%20%20rebate_penalty%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Closed-form%20producer%20response%0A%0A%20%20%20%20The%20producer's%20first-order%20conditions%20equate%20expenditure%20shares.%20With%0A%20%20%20%20%24%5Calpha%3D0.35%24%20and%20net%20clean%20price%20%24p_c%3D12-r%24%2C%20define%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%20%20q(r)%3D%5Cfrac%7B(1-%5Calpha)p_c%7D%7B%5Calpha%5C%2C6%7D.%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20At%20the%20cost-minimizing%20production%20frontier%2C%20%24f%2Fc%3Dq%24%20and%0A%20%20%20%20%24c%5E%5Calpha%20f%5E%7B1-%5Calpha%7D%3D1%24.%20Therefore%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%20%20c%5E%5Cstar(r)%3Dq(r)%5E%7B-(1-%5Calpha)%7D%2C%5Cqquad%0A%20%20%20%20%20%20f%5E%5Cstar(r)%3Dq(r)%5E%5Calpha.%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20These%20formulas%20provide%20an%20independent%20lower-response%20check%20and%20reduce%20the%0A%20%20%20%20policy%20benchmark%20to%20a%20one-dimensional%20bounded%20optimization%20problem.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20clean_list_price%2C%0A%20%20%20%20fossil_price%2C%0A%20%20%20%20fossil_target%2C%0A%20%20%20%20np%2C%0A%20%20%20%20production_elasticity%2C%0A%20%20%20%20rebate_penalty%2C%0A)%3A%0A%20%20%20%20def%20producer_response(rebate_value)%3A%0A%20%20%20%20%20%20%20%20_rebate%20%3D%20np.asarray(rebate_value%2C%20dtype%3Dfloat)%0A%20%20%20%20%20%20%20%20_net_clean_price%20%3D%20clean_list_price%20-%20_rebate%0A%20%20%20%20%20%20%20%20_input_ratio%20%3D%20(1.0%20-%20production_elasticity)%20*%20_net_clean_price%20%2F%20(production_elasticity%20*%20fossil_price)%0A%20%20%20%20%20%20%20%20_clean%20%3D%20_input_ratio%20**%20(-(1.0%20-%20production_elasticity))%0A%20%20%20%20%20%20%20%20_fossil%20%3D%20_input_ratio**production_elasticity%0A%20%20%20%20%20%20%20%20return%20_clean%2C%20_fossil%0A%0A%20%20%20%20def%20policy_objective(rebate_value)%3A%0A%20%20%20%20%20%20%20%20_%2C%20_fossil%20%3D%20producer_response(rebate_value)%0A%20%20%20%20%20%20%20%20return%20(_fossil%20-%20fossil_target)%20**%202%20%2B%20rebate_penalty%20*%20np.asarray(rebate_value)%20**%202%0A%0A%20%20%20%20return%20policy_objective%2C%20producer_response%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Build%20the%20bilevel%20power-cone%20model%0A%0A%20%20%20%20Membership%20of%20%24(c%2Cf%2C1)%24%20in%20%60PowCone3D%60%20with%20exponent%20%240.35%24%20is%20exactly%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%20%20c%5Cgeq0%2C%5Cqquad%20f%5Cgeq0%2C%5Cqquad%0A%20%20%20%20%20%201%5Cleq%20c%5E%7B0.35%7Df%5E%7B0.65%7D.%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20The%20initial%20values%20are%20deterministic%20and%20feasible.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20BilevelProblem%2C%0A%20%20%20%20LowerProblem%2C%0A%20%20%20%20clean_list_price%2C%0A%20%20%20%20cp%2C%0A%20%20%20%20fossil_price%2C%0A%20%20%20%20fossil_target%2C%0A%20%20%20%20initial_rebate%2C%0A%20%20%20%20producer_response%2C%0A%20%20%20%20production_elasticity%2C%0A%20%20%20%20rebate_bounds%2C%0A%20%20%20%20rebate_penalty%2C%0A)%3A%0A%20%20%20%20rebate%20%3D%20cp.Variable(bounds%3Dlist(rebate_bounds)%2C%20name%3D%22clean_equipment_rebate%22)%0A%20%20%20%20clean_input%20%3D%20cp.Variable(name%3D%22clean_input%22)%0A%20%20%20%20fossil_input%20%3D%20cp.Variable(name%3D%22fossil_input%22)%0A%0A%20%20%20%20_initial_clean%2C%20_initial_fossil%20%3D%20producer_response(initial_rebate)%0A%20%20%20%20rebate.value%20%3D%20initial_rebate%0A%20%20%20%20clean_input.value%20%3D%20float(_initial_clean)%0A%20%20%20%20fossil_input.value%20%3D%20float(_initial_fossil)%0A%0A%20%20%20%20producer%20%3D%20LowerProblem(%0A%20%20%20%20%20%20%20%20cp.Minimize((clean_list_price%20-%20rebate)%20*%20clean_input%20%2B%20fossil_price%20*%20fossil_input)%2C%0A%20%20%20%20%20%20%20%20%5Bcp.PowCone3D(clean_input%2C%20fossil_input%2C%201.0%2C%20production_elasticity)%5D%2C%0A%20%20%20%20%20%20%20%20parameters%3D%5Brebate%5D%2C%0A%20%20%20%20)%0A%20%20%20%20problem%20%3D%20BilevelProblem(%0A%20%20%20%20%20%20%20%20cp.Minimize(cp.square(fossil_input%20-%20fossil_target)%20%2B%20rebate_penalty%20*%20cp.square(rebate))%2C%0A%20%20%20%20%20%20%20%20producer%2C%0A%20%20%20%20)%0A%20%20%20%20return%20clean_input%2C%20fossil_input%2C%20problem%2C%20rebate%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(problem%2C%20production_elasticity)%3A%0A%20%20%20%20canonical%20%3D%20problem.canonicalize()%0A%20%20%20%20cone_layout%20%3D%20canonical.cone_layout%0A%0A%20%20%20%20assert%20cone_layout.power_3d%20%3D%3D%20(production_elasticity%2C)%0A%20%20%20%20assert%20len(cone_layout.power_3d_slices)%20%3D%3D%201%0A%20%20%20%20assert%20cone_layout.second_order%20%3D%3D%20()%0A%20%20%20%20assert%20cone_layout.exponential%20%3D%3D%200%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Independent%20scalar%20policy%20benchmark%0A%0A%20%20%20%20Substituting%20the%20closed-form%20producer%20response%20into%20the%20regulator's%0A%20%20%20%20objective%20leaves%20a%20smooth%20scalar%20function%20on%20%24%5B0%2C8%5D%24.%20SciPy's%20bounded%0A%20%20%20%20scalar%20optimizer%20supplies%20an%20independent%20reference%20for%20both%20the%20chosen%0A%20%20%20%20rebate%20and%20its%20induced%20input%20mix.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20minimize_scalar%2C%0A%20%20%20%20np%2C%0A%20%20%20%20policy_objective%2C%0A%20%20%20%20producer_response%2C%0A%20%20%20%20production_elasticity%2C%0A%20%20%20%20rebate_bounds%2C%0A)%3A%0A%20%20%20%20reference%20%3D%20minimize_scalar(%0A%20%20%20%20%20%20%20%20policy_objective%2C%0A%20%20%20%20%20%20%20%20bounds%3Drebate_bounds%2C%0A%20%20%20%20%20%20%20%20method%3D%22bounded%22%2C%0A%20%20%20%20%20%20%20%20options%3D%7B%22xatol%22%3A%201e-13%7D%2C%0A%20%20%20%20)%0A%20%20%20%20assert%20reference.success%2C%20reference.message%0A%0A%20%20%20%20reference_rebate%20%3D%20float(reference.x)%0A%20%20%20%20_reference_clean%2C%20_reference_fossil%20%3D%20producer_response(reference_rebate)%0A%20%20%20%20reference_clean%20%3D%20float(_reference_clean)%0A%20%20%20%20reference_fossil%20%3D%20float(_reference_fossil)%0A%20%20%20%20reference_objective%20%3D%20float(reference.fun)%0A%0A%20%20%20%20np.testing.assert_allclose(%0A%20%20%20%20%20%20%20%20reference_clean**production_elasticity%20*%20reference_fossil%20**%20(1.0%20-%20production_elasticity)%2C%0A%20%20%20%20%20%20%20%201.0%2C%0A%20%20%20%20%20%20%20%20atol%3D1e-12%2C%0A%20%20%20%20%20%20%20%20rtol%3D0.0%2C%0A%20%20%20%20)%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20reference_clean%2C%0A%20%20%20%20%20%20%20%20reference_fossil%2C%0A%20%20%20%20%20%20%20%20reference_objective%2C%0A%20%20%20%20%20%20%20%20reference_rebate%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Solve%20and%20validate%0A%0A%20%20%20%20BLVPY%20solves%20the%20unreduced%20bilevel%20model%20by%20continuation%20to%0A%20%20%20%20%24%5Cepsilon%3D10%5E%7B-5%7D%24.%20We%20then%20evaluate%20the%20exact%20producer%20formula%20at%20the%0A%20%20%20%20returned%20rebate%20and%20compare%20the%20complete%20result%20with%20the%20independently%0A%20%20%20%20minimized%20scalar%20benchmark.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20clean_input%2C%0A%20%20%20%20cp%2C%0A%20%20%20%20fossil_input%2C%0A%20%20%20%20np%2C%0A%20%20%20%20problem%2C%0A%20%20%20%20producer_response%2C%0A%20%20%20%20production_elasticity%2C%0A%20%20%20%20rebate%2C%0A%20%20%20%20rebate_bounds%2C%0A%20%20%20%20reference_clean%2C%0A%20%20%20%20reference_fossil%2C%0A%20%20%20%20reference_objective%2C%0A%20%20%20%20reference_rebate%2C%0A)%3A%0A%20%20%20%20epsilon_target%20%3D%201e-5%0A%20%20%20%20result%20%3D%20problem.solve(%0A%20%20%20%20%20%20%20%20epsilon_initial%3D1e-2%2C%0A%20%20%20%20%20%20%20%20epsilon_target%3Depsilon_target%2C%0A%20%20%20%20%20%20%20%20feasibility_tolerance%3D1e-7%2C%0A%20%20%20%20%20%20%20%20solver%3Dcp.IPOPT%2C%0A%20%20%20%20%20%20%20%20solver_options%3D%7B%22hessian_approximation%22%3A%20%22limited-memory%22%2C%20%22tol%22%3A%201e-8%7D%2C%0A%20%20%20%20%20%20%20%20verbose%3DFalse%2C%0A%20%20%20%20)%0A%20%20%20%20diagnostics%20%3D%20problem.gap_diagnostics(result)%0A%0A%20%20%20%20result_rebate%20%3D%20float(np.asarray(result.variable_values%5Brebate%5D))%0A%20%20%20%20result_clean%20%3D%20float(np.asarray(result.variable_values%5Bclean_input%5D))%0A%20%20%20%20result_fossil%20%3D%20float(np.asarray(result.variable_values%5Bfossil_input%5D))%0A%20%20%20%20_closed_form_clean%2C%20_closed_form_fossil%20%3D%20producer_response(result_rebate)%0A%20%20%20%20closed_form_clean%20%3D%20float(_closed_form_clean)%0A%20%20%20%20closed_form_fossil%20%3D%20float(_closed_form_fossil)%0A%0A%20%20%20%20assert%20result.succeeded%2C%20result.message%0A%20%20%20%20assert%20result.objective%20is%20not%20None%0A%20%20%20%20np.testing.assert_allclose(result.final_epsilon%2C%20epsilon_target%2C%20atol%3D0.0%2C%20rtol%3D0.0)%0A%20%20%20%20assert%20result.residuals.max_violation%20%3C%3D%201e-5%0A%20%20%20%20assert%20result.complementarity%20%3C%3D%201.1%20*%20epsilon_target%0A%20%20%20%20assert%20abs(diagnostics.source_gap)%20%3C%3D%201.1%20*%20epsilon_target%0A%20%20%20%20assert%20rebate_bounds%5B0%5D%20%3C%3D%20result_rebate%20%3C%3D%20rebate_bounds%5B1%5D%0A%0A%20%20%20%20np.testing.assert_allclose(%0A%20%20%20%20%20%20%20%20%5Bresult_clean%2C%20result_fossil%5D%2C%0A%20%20%20%20%20%20%20%20%5Bclosed_form_clean%2C%20closed_form_fossil%5D%2C%0A%20%20%20%20%20%20%20%20atol%3D3e-3%2C%0A%20%20%20%20%20%20%20%20rtol%3D0.0%2C%0A%20%20%20%20)%0A%20%20%20%20np.testing.assert_allclose(result_rebate%2C%20reference_rebate%2C%20atol%3D2e-2%2C%20rtol%3D0.0)%0A%20%20%20%20np.testing.assert_allclose(%0A%20%20%20%20%20%20%20%20%5Bresult_clean%2C%20result_fossil%5D%2C%0A%20%20%20%20%20%20%20%20%5Breference_clean%2C%20reference_fossil%5D%2C%0A%20%20%20%20%20%20%20%20atol%3D3e-3%2C%0A%20%20%20%20%20%20%20%20rtol%3D0.0%2C%0A%20%20%20%20)%0A%20%20%20%20assert%20abs(float(result.objective)%20-%20reference_objective)%20%3C%3D%205e-3%0A%20%20%20%20assert%20result_clean**production_elasticity%20*%20result_fossil%20**%20(1.0%20-%20production_elasticity)%20%3E%3D%201.0%20-%201e-5%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20closed_form_clean%2C%0A%20%20%20%20%20%20%20%20closed_form_fossil%2C%0A%20%20%20%20%20%20%20%20diagnostics%2C%0A%20%20%20%20%20%20%20%20epsilon_target%2C%0A%20%20%20%20%20%20%20%20result%2C%0A%20%20%20%20%20%20%20%20result_clean%2C%0A%20%20%20%20%20%20%20%20result_fossil%2C%0A%20%20%20%20%20%20%20%20result_rebate%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(%0A%20%20%20%20closed_form_clean%2C%0A%20%20%20%20closed_form_fossil%2C%0A%20%20%20%20diagnostics%2C%0A%20%20%20%20epsilon_target%2C%0A%20%20%20%20mo%2C%0A%20%20%20%20reference_clean%2C%0A%20%20%20%20reference_fossil%2C%0A%20%20%20%20reference_objective%2C%0A%20%20%20%20reference_rebate%2C%0A%20%20%20%20result%2C%0A%20%20%20%20result_clean%2C%0A%20%20%20%20result_fossil%2C%0A%20%20%20%20result_rebate%2C%0A)%3A%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20%23%23%20Result%0A%0A%20%20%20%20%7C%20quantity%20%7C%20BLVPY%20result%20%7C%20independent%20reference%20%7C%0A%20%20%20%20%7C%20---%20%7C%20---%3A%20%7C%20---%3A%20%7C%0A%20%20%20%20%7C%20status%20%7C%20%60%7Bresult.status%7D%60%20%7C%20%60success%60%20%7C%0A%20%20%20%20%7C%20clean-equipment%20rebate%20%7C%20%7Bresult_rebate%3A.6f%7D%20%7C%20%7Breference_rebate%3A.6f%7D%20%7C%0A%20%20%20%20%7C%20clean%20input%20%7C%20%7Bresult_clean%3A.6f%7D%20%7C%20%7Breference_clean%3A.6f%7D%20%7C%0A%20%20%20%20%7C%20fossil%20input%20%7C%20%7Bresult_fossil%3A.6f%7D%20%7C%20%7Breference_fossil%3A.6f%7D%20%7C%0A%20%20%20%20%7C%20policy%20objective%20%7C%20%7Bfloat(result.objective)%3A.6f%7D%20%7C%20%7Breference_objective%3A.6f%7D%20%7C%0A%20%20%20%20%7C%20final%20epsilon%20%7C%20%7Bresult.final_epsilon%3A.3e%7D%20%7C%20%7Bepsilon_target%3A.3e%7D%20%7C%0A%20%20%20%20%7C%20maximum%20lifted%20residual%20%7C%20%7Bresult.residuals.max_violation%3A.3e%7D%20%7C%20--%20%7C%0A%20%20%20%20%7C%20complementarity%20%7C%20%7Bresult.complementarity%3A.3e%7D%20%7C%20--%20%7C%0A%20%20%20%20%7C%20signed%20source%20gap%20%7C%20%7Bdiagnostics.source_gap%3A.3e%7D%20%7C%20--%20%7C%0A%0A%20%20%20%20At%20the%20returned%20rebate%2C%20the%20closed-form%20producer%20response%20is%0A%20%20%20%20%24(%7Bclosed_form_clean%3A.6f%7D%2C%20%7Bclosed_form_fossil%3A.6f%7D)%24.%20Its%20agreement%20with%0A%20%20%20%20the%20returned%20lower%20variables%20confirms%20that%20the%20policy%20solution%20respects%0A%20%20%20%20the%20producer's%20cost-minimizing%20response%2C%20while%20the%20separate%20scalar%20solve%0A%20%20%20%20checks%20the%20regulator's%20decision.%20The%20policy%20objective%20is%20shallow%20near%20its%0A%20%20%20%20minimum%2C%20so%20the%20nonzero%20continuation%20allowance%20can%20leave%20a%20small%20visible%0A%20%20%20%20difference%20in%20the%20rebate%20even%20when%20the%20input%20mix%20and%20objective%20agree.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Policy%20response%20curves%0A%0A%20%20%20%20The%20left%20panel%20shows%20how%20a%20larger%20rebate%20lowers%20the%20producer's%20clean-input%0A%20%20%20%20price%2C%20raising%20clean%20use%20and%20reducing%20fossil%20use%20along%20the%20fixed-output%0A%20%20%20%20frontier.%20The%20right%20panel%20shows%20the%20resulting%20tradeoff%20between%20the%20fossil%0A%20%20%20%20target%20and%20the%20rebate%20penalty.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20np%2C%0A%20%20%20%20plt%2C%0A%20%20%20%20policy_objective%2C%0A%20%20%20%20producer_response%2C%0A%20%20%20%20rebate_bounds%2C%0A%20%20%20%20reference_objective%2C%0A%20%20%20%20reference_rebate%2C%0A%20%20%20%20result_clean%2C%0A%20%20%20%20result_fossil%2C%0A%20%20%20%20result_rebate%2C%0A)%3A%0A%20%20%20%20_rebate_grid%20%3D%20np.linspace(rebate_bounds%5B0%5D%2C%20rebate_bounds%5B1%5D%2C%20240)%0A%20%20%20%20_clean_path%2C%20_fossil_path%20%3D%20producer_response(_rebate_grid)%0A%20%20%20%20_policy_path%20%3D%20policy_objective(_rebate_grid)%0A%0A%20%20%20%20_figure%2C%20(_input_axis%2C%20_policy_axis)%20%3D%20plt.subplots(1%2C%202%2C%20figsize%3D(10.5%2C%204.2))%0A%20%20%20%20_input_axis.plot(_rebate_grid%2C%20_clean_path%2C%20linewidth%3D2.0%2C%20label%3D%22Clean%20input%22)%0A%20%20%20%20_input_axis.plot(_rebate_grid%2C%20_fossil_path%2C%20linewidth%3D2.0%2C%20label%3D%22Fossil%20input%22)%0A%20%20%20%20_input_axis.scatter(%0A%20%20%20%20%20%20%20%20%5Bresult_rebate%2C%20result_rebate%5D%2C%0A%20%20%20%20%20%20%20%20%5Bresult_clean%2C%20result_fossil%5D%2C%0A%20%20%20%20%20%20%20%20color%3D%22tab%3Aorange%22%2C%0A%20%20%20%20%20%20%20%20marker%3D%22o%22%2C%0A%20%20%20%20%20%20%20%20s%3D55%2C%0A%20%20%20%20%20%20%20%20zorder%3D3%2C%0A%20%20%20%20%20%20%20%20label%3D%22BLVPY%20solution%22%2C%0A%20%20%20%20)%0A%20%20%20%20_input_axis.set_xlabel(%22Clean-equipment%20rebate%22)%0A%20%20%20%20_input_axis.set_ylabel(%22Normalized%20input%20use%22)%0A%20%20%20%20_input_axis.legend(frameon%3DFalse)%0A%0A%20%20%20%20_policy_axis.plot(_rebate_grid%2C%20_policy_path%2C%20color%3D%220.25%22%2C%20linewidth%3D2.0)%0A%20%20%20%20_policy_axis.scatter(%0A%20%20%20%20%20%20%20%20%5Breference_rebate%5D%2C%0A%20%20%20%20%20%20%20%20%5Breference_objective%5D%2C%0A%20%20%20%20%20%20%20%20color%3D%22tab%3Agreen%22%2C%0A%20%20%20%20%20%20%20%20marker%3D%22*%22%2C%0A%20%20%20%20%20%20%20%20s%3D130%2C%0A%20%20%20%20%20%20%20%20zorder%3D4%2C%0A%20%20%20%20%20%20%20%20label%3D%22Independent%20optimum%22%2C%0A%20%20%20%20)%0A%20%20%20%20_policy_axis.axvline(%0A%20%20%20%20%20%20%20%20result_rebate%2C%0A%20%20%20%20%20%20%20%20color%3D%22tab%3Aorange%22%2C%0A%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20linewidth%3D1.5%2C%0A%20%20%20%20%20%20%20%20label%3D%22BLVPY%20rebate%22%2C%0A%20%20%20%20)%0A%20%20%20%20_policy_axis.set_xlabel(%22Clean-equipment%20rebate%22)%0A%20%20%20%20_policy_axis.set_ylabel(%22Policy%20objective%22)%0A%20%20%20%20_policy_axis.legend(frameon%3DFalse)%0A%0A%20%20%20%20_figure.tight_layout()%0A%20%20%20%20plt.show()%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
24849666158851e66879465686949aa7