import%20marimo%0A%0A__generated_with%20%3D%20%220.18.4%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20return%20(mo%2C)%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!%5BMOSEK%20ApS%5D(https%3A%2F%2Fwww.mosek.com%2Fstatic%2Fimages%2Fbranding%2Fwebgraphmoseklogocolor.png%20)%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%20High-frequency%20transformers%20are%20widely%20used%20in%20power%20electronic%20systems%20where%20compact%20size%20and%20high%20efficiency%20are%20required.%20Their%20design%20involves%20selecting%20appropriate%20winding%20and%20operating%20parameters%20while%20respecting%20physical%20and%20performance%20limitations.%0A%0A%20%20%20%20This%20notebook%20focuses%20on%20the%20systematic%20selection%20of%20transformer%20winding%20parameters%20in%20order%20to%20**minimize%20total%20power%20loss**%2C%20subject%20to%20electrical%2C%20geometric%2C%20and%20thermal%20constraints.%20The%20problem%20is%20formulated%20as%20an%20optimization%20model%20and%20solved%20using%20geometric%20programming.%0A%0A%20%20%20%20The%20model%20is%20based%20on%20the%20work%20presented%20in%20%5BApplication%20of%20Geometric%20Programming%20to%20Transformer%20Design%5D(https%3A%2F%2Fieeexplore.ieee.org%2Fdocument%2F1532335)%20(IEEE%20Transactions%20on%20Magnetics%2C%20vol.%2041%2C%20no.%2011%2C%20pp.%204261-4269%2C%20Nov.%202005)%20by%20Rabih%20A.%20Jabr.%0A%0A%20%20%20%20Geometric%20Programming%20problems%20are%20solved%20by%20convexifying%20them%20in%20a%20standard%20way%20into%20an%20%5Bexponential%20cone%20problem%5D(https%3A%2F%2Fdocs.mosek.com%2Fmodeling-cookbook%2Fexpo.html%23geometric-programming).%20For%20the%20implementation%20we%20use%20a%20Geometric%20Programming%20Toolbox%20developed%20in%20%5Bour%20previous%20notebook%5D(https%3A%2F%2Fdocs.mosek.com%2Ftutorials-notebooks%2Fgp-toolbox%2Fgptoolbox.html).%20It%20accepts%20a%20high-level%20GP%20model%20and%20transforms%20it%20into%20a%20conic%20problem%20expressed%20using%20the%20Python%20Fusion%20API.%20It%20is%20included%20here%20as%20an%20appendix.%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%20Modeling%20Scope%0A%0A%20%20%20%20The%20optimization%20framework%20developed%20in%20this%20work%20is%20designed%20to%20support%20a%20wide%20range%20of%20transformer%20design%20scenarios%20rather%20than%20a%20single%20fixed%20configuration.%20Its%20formulation%20is%20general%20and%20can%20be%20adapted%20to%20different%20operating%20frequencies%2C%20magnetic%20materials%2C%20and%20design%20objectives%20through%20appropriate%20parameter%20choices.%0A%0A%20%20%20%20The%20same%20model%20structure%20applies%20to%20both%20low-%20and%20high-frequency%20transformers.%20Differences%20between%20these%20regimes%20are%20captured%20through%20operating%20frequency%20and%20material-dependent%20loss%20parameters%2C%20allowing%20the%20framework%20to%20represent%20laminated-core%20transformers%20at%20low%20frequency%20as%20well%20as%20ferrite-based%20designs%20at%20high%20frequency.%20In%20the%20*high-frequency*%20case%20study%20presented%20here%2C%20a%20*Mn%E2%80%93Zn%20ferrite*%20core%20is%20used%20to%20demonstrate%20the%20method%20under%20realistic%20operating%20conditions.%0A%0A%20%20%20%20Magnetic%20material%20behavior%20is%20incorporated%20through%20analytical%20core-loss%20models%20and%20flux-density%20constraints.%20Core%20geometry%20may%20either%20be%20fixed%2C%20representing%20a%20preselected%20commercial%20core%2C%20or%20treated%20as%20a%20design%20variable%20when%20core%20sizing%20is%20part%20of%20the%20optimization.%20This%20flexibility%20allows%20the%20framework%20to%20address%20problems%20ranging%20from%20winding%20optimization%20to%20joint%20core%E2%80%93winding%20design.%0A%0A%20%20%20%20Winding%20design%20is%20modeled%20in%20detail%2C%20including%20the%20number%20of%20primary%20and%20secondary%20turns%2C%20current%20density%2C%20conductor%20dimensions%2C%20and%20layer%20structure.%20Geometric%20feasibility%20is%20enforced%20through%20constraints%20that%20ensure%20the%20windings%20fit%20within%20the%20available%20core%20window%20while%20accounting%20for%20insulation%20and%20manufacturing%20allowances.%20High-frequency%20effects%20are%20captured%20using%20effective%20resistance%20models.%0A%0A%20%20%20%20Electrical%2C%20magnetic%2C%20geometric%2C%20and%20thermal%20effects%20are%20modeled%20simultaneously.%20Core%20loss%2C%20copper%20loss%2C%20voltage%20regulation%2C%20magnetizing%20current%2C%20and%20temperature%20rise%20are%20represented%20using%20analytical%20expressions%20that%20can%20be%20formulated%20in%20monomial%20or%20posynomial%20form%2C%20enabling%20efficient%20optimization%20while%20capturing%20the%20key%20trade-offs%20in%20practical%20transformer%20design.%0A%0A%20%20%20%20Different%20design%20objectives%20can%20be%20explored%20within%20the%20same%20framework%20by%20modifying%20the%20optimization%20objective%2C%20including%3A%0A%0A%20%20%20%20-%20Minimum%20mass%0A%0A%20%20%20%20-%20Minimum%20loss%0A%0A%20%20%20%20-%20Maximum%20apparent%20power%20(VA).%0A%0A%20%20%20%20The%20example%20presented%20in%20this%20work%20focuses%20on%20a%20minimum-loss%20design%20for%20a%20high-frequency%20transformer%20with%20fixed%20core%20geometry%20and%20foil%20windings.%20The%20optimization%20selects%20the%20winding%20configuration%20and%20operating%20point%2C%20specifically%20the%20number%20of%20turns%2C%20number%20of%20layers%2C%20flux%20density%2C%20and%20current%20density%2C%20such%20that%20losses%20are%20minimized%20while%20all%20electrical%2C%20thermal%2C%20and%20geometric%20constraints%20are%20satisfied.%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%20Mathematical%20Model%0A%0A%20%20%20%20%23%23%20Decision%20Variables%0A%0A%20%20%20%20All%20decision%20variables%20are%20strictly%20positive.%0A%0A%20%20%20%20%7C%20Symbol%20%7C%20Description%20%7C%20Unit%20%7C%0A%20%20%20%20%7C------%7C------------%7C------%7C%0A%20%20%20%20%7C%20%5C(%20N_p%20%5C)%20%7C%20Number%20of%20primary%20turns%20%7C%20%E2%80%93%20%7C%0A%20%20%20%20%7C%20%5C(%20N_s%20%5C)%20%7C%20Number%20of%20secondary%20turns%20%7C%20%E2%80%93%20%7C%0A%20%20%20%20%7C%20%5C(%20N_%7Bls%7D%20%5C)%20%7C%20Number%20of%20secondary%20winding%20layers%20%7C%20%E2%80%93%20%7C%0A%20%20%20%20%7C%20%5C(%20B%20%5C)%20%7C%20Peak%20magnetic%20flux%20density%20%7C%20T%20%7C%0A%20%20%20%20%7C%20%5C(%20J%20%5C)%20%7C%20Current%20density%20%7C%20A%2Fm%5C(%5E2%5C)%20%7C%0A%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%20Auxiliary%20Variables%0A%0A%20%20%20%20%7C%20Symbol%20%7C%20Description%20%7C%20Unit%20%7C%0A%20%20%20%20%7C------%7C------------%7C------%7C%0A%20%20%20%20%7C%20%5C(%20%5Cbar%7BP%7D_%7Bc%7D%20%5C)%20%7C%20Upper%20bound%20on%20core%20loss%20%7C%20W%20%7C%0A%20%20%20%20%7C%20%5C(%20%5Cbar%7BP%7D_%7Bcu%7D%20%5C)%20%7C%20Upper%20bound%20on%20copper%20loss%20%7C%20W%20%7C%0A%20%20%20%20%7C%20%5C(%20%5Cbar%7BV%7D_%7BR%2Cr%7D%20%5C)%20%7C%20Upper%20bound%20on%20resistive%20voltage%20regulation%20%7C%20%E2%80%93%20%7C%0A%20%20%20%20%7C%20%5C(%20%5Cbar%7BV%7D_%7BR%2Cx%7D%20%5C)%20%7C%20Upper%20bound%20on%20reactive%20voltage%20regulation%20%7C%20%E2%80%93%20%7C%0A%20%20%20%20%7C%20%5C(%20%5Cbar%7BI%7D_m%20%5C)%20%7C%20Upper%20bound%20on%20magnetizing%20current%20%7C%20A%20%7C%0A%20%20%20%20%7C%20%5C(%20%5Cbar%7Bh%7D%20%5C)%20%7C%20Thermal%20resistance%20factor%20%7C%20K%2FW%20%7C%0A%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%20Parameters%0A%0A%20%20%20%20%7C%20**Symbol**%20%7C%20Description%20%7C%20Unit%20%7C%20%20%7C%20**Symbol**%20%7C%20Description%20%7C%20Unit%20%7C%0A%20%20%20%20%7C-----------%7C------------%7C------%7C--%7C-----------%7C------------%7C------%7C%0A%20%20%20%20%7C%20**%5C(%20V_p%20%5C)**%20%7C%20Rated%20primary%20voltage%20%7C%20V%20%7C%20%20%7C%20**%5C(%20V_s%20%5C)**%20%7C%20Rated%20secondary%20voltage%20%7C%20V%20%7C%0A%20%20%20%20%7C%20**%5C(%20P_o%20%5C)**%20%7C%20Rated%20output%20power%20%7C%20W%20%7C%20%20%7C%20**%5C(%20f%20%5C)**%20%7C%20Operating%20frequency%20%7C%20Hz%20%7C%0A%20%20%20%20%7C%20**%5C(%20I_p%20%5C)**%20%7C%20Rated%20primary%20current%20%7C%20A%20%7C%20%20%7C%20**%5C(%20I_s%20%5C)**%20%7C%20Rated%20secondary%20current%20%7C%20A%20%7C%0A%20%20%20%20%7C%20**%5C(%20A_c%20%5C)**%20%7C%20Core%20cross-sectional%20area%20%7C%20m%5C(%5E2%5C)%20%7C%20%20%7C%20**%5C(%20V_c%20%5C)**%20%7C%20Core%20volume%20%7C%20m%5C(%5E3%5C)%20%7C%0A%20%20%20%20%7C%20**%5C(%20c%20%5C)**%20%7C%20Core%20window%20depth%20%7C%20m%20%7C%20%20%7C%20**%5C(%20t%20%5C)**%20%7C%20Core%20thickness%20%7C%20m%20%7C%0A%20%20%20%20%7C%20**%5C(%20b_w%20%5C)**%20%7C%20Window%20width%20%7C%20m%20%7C%20%20%7C%20**%5C(%20h_w%20%5C)**%20%7C%20Window%20height%20%7C%20m%20%7C%0A%20%20%20%20%7C%20**%5C(%20%5Crho_w%20%5C)**%20%7C%20Copper%20resistivity%20%7C%20%CE%A9%C2%B7m%20%7C%20%20%7C%20**%5C(%20d%20%5C)**%20%7C%20Foil%20thickness%20%7C%20m%20%7C%0A%20%20%20%20%7C%20**%5C(%20F_r%20%5C)**%20%7C%20AC%2FDC%20resistance%20ratio%20%7C%20%E2%80%93%20%7C%20%20%7C%20**%5C(%20F_%5Cell%20%5C)**%20%7C%20Layer%20utilization%20factor%20%7C%20%E2%80%93%20%7C%0A%20%20%20%20%7C%20**%5C(%20B_%7B%5Cmax%7D%20%5C)**%20%7C%20Maximum%20flux%20density%20%7C%20T%20%7C%20%20%7C%20**%5C(%20%5CDelta%20T_%7B%5Cmax%7D%20%5C)**%20%7C%20Maximum%20temperature%20rise%20%7C%20K%20%7C%0A%20%20%20%20%7C%20**%5C(%20k_c%20%5C)**%20%7C%20Core%20loss%20coefficient%20%7C%20%E2%80%93%20%7C%20%20%7C%20**%5C(%20%5Calpha%20%5C)**%20%7C%20Frequency%20exponent%20%7C%20%E2%80%93%20%7C%0A%20%20%20%20%7C%20**%5C(%20%5Cbeta%20%5C)**%20%7C%20Flux%20density%20exponent%20%7C%20%E2%80%93%20%7C%20%20%7C%20**%5C(%20k_v%20%5C)**%20%7C%20Waveform%20constant%20%7C%20%E2%80%93%20%7C%0A%0A%0A%0A%20%20%20%20---%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%20All%20formulas%20are%20numbered%20as%20in%20the%20original%20paper.%20The%20derivation%20of%20the%20geometric%20programming%20formulation%20and%20the%20detailed%20discussion%20of%20the%20individual%20constraints%20can%20be%20found%20in%20the%20referenced%20work.%20The%20implemented%20model%20used%20in%20this%20study%20is%20defined%20in%20the%20following%20section.%0A%0A%20%20%20%20%23%23%23%20Objective%20Function%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Cmin%20%5Cquad%20%5Cbar%7BP%7D_%7Bc%7D%20%2B%20%5Cbar%7BP%7D_%7Bcu%7D%0A%20%20%20%20%5C%5D%0A%0A%0A%20%20%20%20%23%23%23%20Induced%20Voltage%20and%20Turns%20Ratio%20Constraints%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B33%7D%0A%20%20%20%202%5E%7B3%2F2%7D%5C%2C%5Cpi%5C%2Ck_f%5C%2Cf%5C%2CE_p%5E%7B-1%7D%5C%2CN_p%5C%2CB%5C%2Cc%5C%2Ct%20%3D%201%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B34%7D%0A%20%20%20%20E_s%5C%2CE_p%5E%7B-1%7D%5C%2CN_s%5E%7B-1%7D%5C%2CN_p%20%3D%201%0A%20%20%20%20%5C%5D%0A%0A%0A%20%20%20%20%23%23%23%20Geometric%20%2F%20Window%20Utilization%20Constraints%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B35%7D%0A%20%20%20%202%5C%2Ck_%7BCu%7D%5E%7B-1%7D%5C%2CN_p%5C%2CI_p%5C%2CJ%5E%7B-1%7D%5C%2Cb_w%5E%7B-1%7D%5C%2Ch_w%5E%7B-1%7D%20%3D%201%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B36%7D%0A%20%20%20%20F_%5Cell%5E%7B-1%7D%5C%2C%20d%5E%7B-1%7D%5C%2C%20I_p%5C%2C%20J%5E%7B-1%7D%5C%2C%20N_p%5C%2C%20N_s%5E%7B-1%7D%5C%2C%20N_%7Bls%7D%5C%2C%20h_w%5E%7B-1%7D%20%3D%201%0A%20%20%20%20%5C%5D%0A%0A%0A%20%20%20%20%23%23%23%20Thermal%20Constraints%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B37%7D%0A%20%20%20%20%5Cfrac%7B%0A%20%20%20%20%5Cbar%7BP%7D_%7Bc%7D%5C%2C%5Cbar%7Bh%7D%5E%7B1%2F4%7D%5C%2Cc%5E%7B-1%2F2%7D%5C%2Ct%5E%7B-1%2F2%7D%5C%2Cb_w%5E%7B-1%2F2%7D%5C%2Ch_w%5E%7B-1%2F2%7D%0A%20%20%20%20%7D%7B%0A%20%20%20%201.42%5Csqrt%7B2%7D%5C%2Ck_a%5C%2C%5CDelta%20T%5E%7B5%2F4%7D%0A%20%20%20%20%7D%20%2B%0A%20%20%20%20%5Cfrac%7B%0A%20%20%20%20%5Cbar%7BP%7D_%7Bcu%7D%5C%2C%5Cbar%7Bh%7D%5E%7B1%2F4%7D%5C%2Cc%5E%7B-1%2F2%7D%5C%2Ct%5E%7B-1%2F2%7D%5C%2Cb_w%5E%7B-1%2F2%7D%5C%2Ch_w%5E%7B-1%2F2%7D%0A%20%20%20%20%7D%7B%0A%20%20%20%201.42%5Csqrt%7B2%7D%5C%2Ck_a%5C%2C%5CDelta%20T%5E%7B5%2F4%7D%0A%20%20%20%20%7D%0A%20%20%20%20%5C%3B%5Cle%5C%3B%201%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B38%7D%0A%20%20%20%20h_w%5C%2C%5Cbar%7Bh%7D%5E%7B-1%7D%20%2B%202c%5C%2C%5Cbar%7Bh%7D%5E%7B-1%7D%20%5Cle%201%0A%20%20%20%20%5C%5D%0A%0A%0A%20%20%20%20%23%23%23%20Loss%20Models%20and%20(Optional)%20Efficiency-Based%20Loss%20Bound%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B39%7D%0A%20%20%20%204k_f%20K_c%20%5Crho_c%20f%5E%7B%5Calpha%7D%20B%5E%7B%5Cbeta%7D%20c%20t%20b_w%5C%2C%20%5Cbar%7BP%7D_c%5E%7B-1%7D%0A%20%20%20%20%5C%3B%2B%5C%3B%0A%20%20%20%208k_f%20K_c%20%5Crho_c%20f%5E%7B%5Calpha%7D%20B%5E%7B%5Cbeta%7D%20c%5E2%20t%5C%2C%20%5Cbar%7BP%7D_c%5E%7B-1%7D%0A%20%20%20%20%5C%3B%2B%5C%3B%0A%20%20%20%204k_f%20K_c%20%5Crho_c%20f%5E%7B%5Calpha%7D%20B%5E%7B%5Cbeta%7D%20c%20t%20b_w%5C%2C%20%5Cbar%7BP%7D_c%5E%7B-1%7D%0A%20%20%20%20%5C%3B%5Cle%5C%3B%201%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B40%7D%0A%20%20%20%204k_%7BCu%7DF_r%5Crho_w%20c%20b_w%20h_w%20J%5E%7B2%7D%5C%2C%5Cbar%7BP%7D_%7Bcu%7D%5E%7B-1%7D%0A%20%20%20%20%5C%3B%2B%5C%3B%0A%20%20%20%202k_%7BCu%7DF_r%5Crho_w%20t%20b_w%20h_w%20J%5E%7B2%7D%5C%2C%5Cbar%7BP%7D_%7Bcu%7D%5E%7B-1%7D%0A%20%20%20%20%5C%3B%2B%5C%3B%0A%20%20%20%20%5Cpi%20k_%7BCu%7DF_r%5Crho_w%20b_w%5E%7B2%7D%20h_w%20J%5E%7B2%7D%5C%2C%5Cbar%7BP%7D_%7Bcu%7D%5E%7B-1%7D%0A%20%20%20%20%5C%3B%5Cle%5C%3B%201%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B41%7D%0A%20%20%20%20%5Cfrac%7B%5Ceta_m%7D%7B(1-%5Ceta_m)P_o%7D%5C%2C%5Cbar%7BP%7D_%7Bcu%7D%0A%20%20%20%20%5C%3B%2B%5C%3B%0A%20%20%20%20%5Cfrac%7B%5Ceta_m%7D%7B(1-%5Ceta_m)P_o%7D%5C%2C%5Cbar%7BP%7D_%7Bc%7D%0A%20%20%20%20%5C%3B%5Cle%5C%3B%201%0A%20%20%20%20%5C%5D%0A%0A%0A%0A%20%20%20%20%23%23%23%20Magnetizing%20%2F%20No-Load%20Current%20Constraints%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B42%7D%0A%20%20%20%20%5Cfrac%7B%5Csqrt%7B2%7D%7D%7B%5Cmu%7D%5C%2C%20B%5C%2C%20N_p%5E%7B-1%7D%5C%2C%20h_w%5C%2C%20%5Cbar%7BI%7D_m%5E%7B-1%7D%0A%20%20%20%20%5C%3B%2B%5C%3B%0A%20%20%20%20%5Cfrac%7B%5Csqrt%7B2%7D%7D%7B%5Cmu%7D%5C%2C%20B%5C%2C%20N_p%5E%7B-1%7D%5C%2C%20b_w%5C%2C%20%5Cbar%7BI%7D_m%5E%7B-1%7D%0A%20%20%20%20%5C%3B%2B%5C%3B%0A%20%20%20%20%5Cfrac%7B2%5Csqrt%7B2%7D%7D%7B%5Cmu%7D%5C%2C%20B%5C%2C%20N_p%5E%7B-1%7D%5C%2C%20c%5C%2C%20%5Cbar%7BI%7D_m%5E%7B-1%7D%0A%20%20%20%20%5C%3B%5Cle%5C%3B%201%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B43%7D%0A%20%20%20%20B_%7B%5Ctext%7Bsat%7D%7D%5E%7B-1%7D%5C%2C%20B%20%5Cle%201%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B44%7D%0A%20%20%20%20k_%7B%5Cvarphi%7D%5E%7B-2%7D%5C%2C%20I_p%5E%7B-2%7D%5C%2C%20%5Cbar%7BI%7D_m%5E2%0A%20%20%20%20%5C%3B%2B%5C%3B%0A%20%20%20%20E_p%5E%7B-2%7D%5C%2C%20k_%7B%5Cvarphi%7D%5E%7B-2%7D%5C%2C%20I_p%5E%7B-2%7D%5C%2C%20%5Cbar%7BP%7D_c%5E%7B2%7D%0A%20%20%20%20%5C%3B%5Cle%5C%3B%201%0A%20%20%20%20%5C%5D%0A%0A%0A%20%20%20%20%23%23%23%20Voltage%20Regulation%20Constraints%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B45%7D%0A%20%20%20%208F_r%5Crho_w%5C%2C%5Ctext%7Bpf%7D%5C%2CN_p%20c%5C%2C%20J%5C%2C%20%5Cbar%7BV%7D_R%5E%7B-1%7D%0A%20%20%20%20%5C%3B%2B%5C%3B%0A%20%20%20%204F_r%5Crho_w%5C%2C%5Ctext%7Bpf%7D%5C%2CN_p%20t%5C%2C%20J%5C%2C%20%5Cbar%7BV%7D_R%5E%7B-1%7D%0A%20%20%20%20%5C%3B%2B%5C%3B%0A%20%20%20%202%5Cpi%20F_r%5Crho_w%5C%2C%5Ctext%7Bpf%7D%5C%2CN_p%20b_w%5C%2C%20J%5C%2C%20%5Cbar%7BV%7D_R%5E%7B-1%7D%0A%20%20%20%20%5C%3B%5Cle%5C%3B%201%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B46%7D%0A%20%20%20%20%5Cfrac%7B8%5Cpi%7D%7B3p%5E%7B2%7D%7D%5C%2C%20I_p%5C%2C%20r_f%5C%2C%20f%5C%2C%20%5Cmu_0%5C%2C%20N_p%5E%7B2%7D%5C%2C%20c%5C%2C%20b_w%5C%2C%20h_w%5E%7B-1%7D%5C%2C%20%5Cbar%7BV%7D_X%5E%7B-1%7D%0A%20%20%20%20%5C%3B%2B%5C%3B%0A%20%20%20%20%5Cfrac%7B4%5Cpi%7D%7B3p%5E%7B2%7D%7D%5C%2C%20I_p%5C%2C%20r_f%5C%2C%20f%5C%2C%20%5Cmu_0%5C%2C%20N_p%5E%7B2%7D%5C%2C%20t%5C%2C%20b_w%5C%2C%20h_w%5E%7B-1%7D%5C%2C%20%5Cbar%7BV%7D_X%5E%7B-1%7D%0A%20%20%20%20%5C%3B%2B%5C%3B%0A%20%20%20%20%5Cfrac%7B2%5Cpi%5E%7B2%7D%7D%7B3p%5E%7B2%7D%7D%5C%2C%20I_p%5C%2C%20r_f%5C%2C%20f%5C%2C%20%5Cmu_0%5C%2C%20N_p%5E%7B2%7D%5C%2C%20b_w%5E%7B2%7D%5C%2C%20h_w%5E%7B-1%7D%5C%2C%20%5Cbar%7BV%7D_X%5E%7B-1%7D%0A%20%20%20%20%5C%3B%5Cle%5C%3B%201%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B48%7D%0A%20%20%20%20E_p%5E%7B-1%7D%5C%2C%20%7BVR%7D_%7Bm%7D%5E%7B-1%7D%5C%2C%20%5Cbar%7BV%7D_R%0A%20%20%20%20%5C%3B%2B%5C%3B%0A%20%20%20%20E_p%5E%7B-1%7D%5C%2C%20%7BVR%7D_%7Bm%7D%5E%7B-1%7D%5C%2C%20%5Cbar%7BV%7D_X%0A%20%20%20%20%5C%3B%5Cle%5C%3B%201%0A%20%20%20%20%5C%5D%0A%0A%0A%20%20%20%20%23%23%23%20Discrete%20%2F%20Structural%20Bounds%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctag%7B47%7D%0A%20%20%20%20N_%7Bls%7D%5E%7B-1%7D%20%5Cle%201%2C%0A%20%20%20%20%5Cqquad%0A%20%20%20%20m%5C%2CN_s%5E%7B-1%7D%5C%2CN_%7Bls%7D%20%5Cle%201%0A%20%20%20%20%5C%5D%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%20Implementation%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%20As%20a%20helper%20for%20writing%20down%20the%20model%2C%20given%20its%20size%2C%20we%20introduce%20a%20compact%20variable%20indexing%20scheme.%0A%20%20%20%20The%20optimization%20variables%20are%20listed%20in%20%60var_names%60%20and%20stored%20internally%20as%20a%20vector.%0A%20%20%20%20The%20dictionary%20%60vid%60%20maps%20each%20symbolic%20variable%20name%20to%20its%20corresponding%20index%20in%20this%20vector%2C%20enabling%20an%20efficient%20numerical%20representation%20of%20monomials%20in%20the%20GP%20solver.%0A%20%20%20%20The%20variable%20%60n%60%20denotes%20the%20total%20number%20of%20optimization%20variables.%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%20var_names%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22c%22%2C%22t%22%2C%22bw%22%2C%22hw%22%2C%22Np%22%2C%22Ns%22%2C%22Nls%22%2C%22B%22%2C%22J%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Pcbar%22%2C%22Pcubar%22%2C%22VRrbar%22%2C%22VRxbar%22%2C%22Imbar%22%2C%22hbar%22%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20vid%20%3D%20%7Bname%3Ai%20for%20i%2Cname%20in%20enumerate(var_names)%7D%0A%20%20%20%20n%20%3D%20len(var_names)%0A%20%20%20%20return%20n%2C%20vid%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%23%20Monomial%20Construction%20Helper%0A%0A%20%20%20%20The%20function%20%60mon(coef%2C%20exps)%60%20is%20a%20helper%20routine%20used%20to%20construct%20monomial%20terms%20in%20a%20readable%20way.%0A%0A%20%20%20%20The%20argument%20%60coef%60%20represents%20the%20positive%20scalar%20coefficient%20of%20the%20monomial%2C%20while%20%60exps%60%20is%20a%20dictionary%20that%20maps%20variable%20names%20to%20their%20corresponding%20exponents.%0A%20%20%20%20Using%20the%20variable%20index%20mapping%20%60vid%60%2C%20the%20function%20converts%20symbolic%20variable%20names%20into%20numerical%20indices%20required%20by%20the%20GP%20solver.%0A%0A%20%20%20%20Variables%20with%20zero%20exponent%20are%20omitted%20to%20keep%20the%20monomial%20representation%20sparse.%0A%20%20%20%20The%20function%20returns%20a%20%60Monomial%60%20object%20in%20the%20internal%20format%20expected%20by%20the%20optimization%20toolbox.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(Monomial%2C%20vid)%3A%0A%20%20%20%20def%20mon(coef%2C%20exps)%3A%0A%20%20%20%20%20%20%20%20idx%2C%20alp%20%3D%20%5B%5D%2C%20%5B%5D%0A%20%20%20%20%20%20%20%20for%20k%2C%20v%20in%20exps.items()%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20v%20%3D%3D%200%3A%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20continue%0A%20%20%20%20%20%20%20%20%20%20%20%20idx.append(vid%5Bk%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20alp.append(v)%0A%20%20%20%20%20%20%20%20return%20Monomial.add(coef%2C%20idx%2C%20alp)%0A%20%20%20%20return%20(mon%2C)%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%20The%20function%20%60fix_var(gp%2C%20k%2C%20name%2C%20value)%60%20enforces%20a%20fixed%20value%20for%20an%20optimization%20variable%20using%20geometric%20programming%E2%80%93compatible%20constraints.%0A%0A%20%20%20%20Since%20GP%20does%20not%20support%20equality%20constraints%20directly%2C%20the%20equality%20%5C(%20x%20%3D%20%5Ctext%7Bvalue%7D%20%5C)%20is%20imposed%20by%20two%20monomial%20inequalities%3A%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Cfrac%7Bx%7D%7B%5Ctext%7Bvalue%7D%7D%20%5Cle%201%2C%20%5Cqquad%20%5Cfrac%7B%5Ctext%7Bvalue%7D%7D%7Bx%7D%20%5Cle%201.%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20These%20constraints%20are%20added%20sequentially%20to%20the%20GP%20model%20starting%20at%20index%20%60k%60%2C%20and%20the%20updated%20constraint%20index%20is%20returned.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mon)%3A%0A%20%20%20%20def%20fix_var(gp%2C%20k%2C%20name%2C%20value)%3A%0A%20%20%20%20%20%20%20%20%23%20Enforce%20x%20%3D%20value%20using%20two%20monomial%20inequalities%3A%0A%20%20%20%20%20%20%20%20%23%20%20%20x%2Fvalue%20%3C%3D%201%0A%20%20%20%20%20%20%20%20%23%20%20%20value%2Fx%20%3C%3D%201%0A%20%20%20%20%20%20%20%20gp.addConstraint(k%2C%20%20%20%5Bmon(1.0%2Fvalue%2C%20%7Bname%3A%201%7D)%5D)%3B%20%20k%20%2B%3D%201%0A%20%20%20%20%20%20%20%20gp.addConstraint(k%2C%20%20%20%5Bmon(value%2C%20%20%20%20%20%7Bname%3A-1%7D)%5D)%3B%20%20k%20%2B%3D%201%0A%20%20%20%20%20%20%20%20return%20k%0A%20%20%20%20return%20(fix_var%2C)%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%23%20Equality%20Constraint%20Helper%0A%0A%20%20%20%20The%20function%20%60add_eq_as_two_ineq(gp%2C%20k%2C%20coef%2C%20exps)%60%20enforces%20a%20monomial%20equality%20constraint%20of%20the%20form%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctext%7Bcoef%7D%20%5Ccdot%20%5Cprod_i%20x_i%5E%7Ba_i%7D%20%3D%201%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20using%20two%20GP-compatible%20inequality%20constraints%3A%0A%0A%20%20%20%20%5C%5B%0A%20%20%20%20%5Ctext%7Bcoef%7D%20%5Ccdot%20%5Cprod_i%20x_i%5E%7Ba_i%7D%20%5Cle%201%2C%20%5Cqquad%0A%20%20%20%20%5Cfrac%7B1%7D%7B%5Ctext%7Bcoef%7D%7D%20%5Ccdot%20%5Cprod_i%20x_i%5E%7B-a_i%7D%20%5Cle%201.%0A%20%20%20%20%5C%5D%0A%0A%20%20%20%20This%20construction%20is%20necessary%20because%20geometric%20programming%20supports%20only%20inequality%20constraints.%0A%20%20%20%20The%20function%20appends%20the%20two%20constraints%20starting%20at%20index%20%60k%60%20and%20returns%20the%20updated%20constraint%20index.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mon)%3A%0A%20%20%20%20def%20add_eq_as_two_ineq(gp%2C%20k%2C%20coef%2C%20exps)%3A%0A%20%20%20%20%20%20%20%20%23%20Enforce%20coef%20*%20%CE%A0%20x%5Ea%20%3D%201%20%20via%20two%20inequalities%3A%0A%20%20%20%20%20%20%20%20%23%20%20%20coef%20*%20%CE%A0%20x%5Ea%20%3C%3D%201%0A%20%20%20%20%20%20%20%20%23%20%20%20(1%2Fcoef)%20*%20%CE%A0%20x%5E%7B-a%7D%20%3C%3D%201%0A%20%20%20%20%20%20%20%20gp.addConstraint(k%2C%20%20%20%5Bmon(coef%2C%20exps)%5D)%0A%20%20%20%20%20%20%20%20gp.addConstraint(k%2B1%2C%20%5Bmon(1.0%2Fcoef%2C%20%7Bname%3A%20-a%20for%20name%2C%20a%20in%20exps.items()%7D)%5D)%0A%20%20%20%20%20%20%20%20return%20k%20%2B%202%0A%20%20%20%20return%20(add_eq_as_two_ineq%2C)%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%23%20Model%20Parameters%0A%0A%20%20%20%20This%20section%20defines%20the%20numerical%20parameters%20used%20in%20the%20geometric%20programming%20model.%0A%0A%20%20%20%20The%20parameters%20include%20fixed%20core%20dimensions%20for%20the%20minimum-loss%20design%2C%20electrical%20specifications%20(rated%20power%2C%20voltages%2C%20frequency%2C%20and%20power%20factor)%2C%20winding%20and%20conductor%20choices%2C%20core%20and%20copper%20material%20properties%2C%20electromagnetic%20constants%2C%20and%20additional%20empirical%20factors%20used%20in%20the%20loss%2C%20thermal%2C%20and%20regulation%20models.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(math)%3A%0A%20%20%20%20%23%20----%20Fixed%20core%20dimensions%20(minimum-loss%20design)%20----%0A%20%20%20%20c0%20%20%3D%200.005%0A%20%20%20%20t0%20%20%3D%200.015%0A%20%20%20%20bw0%20%3D%200.010%0A%20%20%20%20hw0%20%3D%200.025%0A%0A%20%20%20%20%23%20----%20Spec%20(HF%20ferrite%20example)%20----%0A%20%20%20%20S%20%20%20%3D%201200.0%20%20%20%20%20%20%23%20VA%0A%20%20%20%20Ep%20%20%3D%20300.0%20%20%20%20%20%20%20%23%20V%0A%20%20%20%20Es%20%20%3D%2075.0%20%20%20%20%20%20%20%20%23%20V%0A%20%20%20%20f%20%20%20%3D%20100e3%20%20%20%20%20%20%20%23%20Hz%0A%20%20%20%20pf%20%20%3D%200.80%0A%20%20%20%20rf%20%20%3D%20math.sqrt(1.0%20-%20pf**2)%0A%20%20%20%20VRm%20%3D%200.03%0A%20%20%20%20eta_m%20%3D%200.97%0A%20%20%20%20k_phi%20%3D%200.02%0A%20%20%20%20dT%20%20%3D%2065.0%0A%0A%20%20%20%20%23%20Full-load%20primary%20current%0A%20%20%20%20Ip%20%3D%20S%20%2F%20Ep%20%20%20%20%20%20%20%23%204.0%20A%0A%0A%20%20%20%20%23%20----%20Winding%20choices%20(HF%20copper%20foil)%20----%0A%20%20%20%20m_layers%20%3D%202%0A%20%20%20%20d_foil%20%20%20%3D%200.238e-3%0A%20%20%20%20kCu%20%20%20%20%20%20%3D%200.6%0A%0A%20%20%20%20%23%20----%20Core%20material%3A%20Mn%E2%80%93Zn%20ferrite%20----%0A%20%20%20%20rho_c%20%3D%204800.0%0A%20%20%20%20Kc%20%20%20%20%3D%201.9e-3%0A%20%20%20%20alpha%20%3D%201.24%0A%20%20%20%20beta%20%20%3D%202.0%0A%20%20%20%20Bsat%20%20%3D%200.4%0A%0A%20%20%20%20%23%20----%20Copper%20material%20----%0A%20%20%20%20rho_Cu%20%3D%208920.0%0A%20%20%20%20rho_w%20%20%3D%202.26e-8%0A%0A%20%20%20%20%23%20----%20EM%20constants%20----%0A%20%20%20%20mu0%20%3D%204e-7%20*%20math.pi%0A%20%20%20%20mu%20%20%3D%20mu0%20*%202000.0%0A%0A%20%20%20%20%23%20----%20Remaining%20model%20factors%20----%0A%20%20%20%20kf%20%3D%200.95%0A%20%20%20%20ka%20%3D%208%20*%20100**1.75%0A%20%20%20%20Fr%20%3D%201.32%0A%20%20%20%20Fl%20%3D%200.9%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20Bsat%2C%0A%20%20%20%20%20%20%20%20Ep%2C%0A%20%20%20%20%20%20%20%20Es%2C%0A%20%20%20%20%20%20%20%20Fl%2C%0A%20%20%20%20%20%20%20%20Fr%2C%0A%20%20%20%20%20%20%20%20Ip%2C%0A%20%20%20%20%20%20%20%20Kc%2C%0A%20%20%20%20%20%20%20%20S%2C%0A%20%20%20%20%20%20%20%20VRm%2C%0A%20%20%20%20%20%20%20%20alpha%2C%0A%20%20%20%20%20%20%20%20beta%2C%0A%20%20%20%20%20%20%20%20bw0%2C%0A%20%20%20%20%20%20%20%20c0%2C%0A%20%20%20%20%20%20%20%20dT%2C%0A%20%20%20%20%20%20%20%20d_foil%2C%0A%20%20%20%20%20%20%20%20f%2C%0A%20%20%20%20%20%20%20%20hw0%2C%0A%20%20%20%20%20%20%20%20kCu%2C%0A%20%20%20%20%20%20%20%20k_phi%2C%0A%20%20%20%20%20%20%20%20ka%2C%0A%20%20%20%20%20%20%20%20kf%2C%0A%20%20%20%20%20%20%20%20m_layers%2C%0A%20%20%20%20%20%20%20%20mu%2C%0A%20%20%20%20%20%20%20%20mu0%2C%0A%20%20%20%20%20%20%20%20pf%2C%0A%20%20%20%20%20%20%20%20rf%2C%0A%20%20%20%20%20%20%20%20rho_Cu%2C%0A%20%20%20%20%20%20%20%20rho_c%2C%0A%20%20%20%20%20%20%20%20rho_w%2C%0A%20%20%20%20%20%20%20%20t0%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%20In%20the%20following%20part%2C%20all%20the%20defined%20Geometric%20Programming%20Model%20is%20implemented.%20For%20different%20design%20options%20and%20frequency%20selection%2C%20the%20objective%20function%20and%20the%20active%20constraints%20can%20change%20accordingly.%0A%0A%20%20%20%20For%20minimum%20loss%20design%20the%20efficiency%20constraint%20(41)%2C%20is%20not%20used%20as%20defined%20in%20the%20paper.%20The%20full%20model%20can%20be%20displayed%20using%20%60printModel()%60%20function%20of%20GP%20Toolbox.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20Bsat%2C%0A%20%20%20%20Ep%2C%0A%20%20%20%20Es%2C%0A%20%20%20%20Fl%2C%0A%20%20%20%20Fr%2C%0A%20%20%20%20GeometricProgramming%2C%0A%20%20%20%20Ip%2C%0A%20%20%20%20Kc%2C%0A%20%20%20%20VRm%2C%0A%20%20%20%20add_eq_as_two_ineq%2C%0A%20%20%20%20alpha%2C%0A%20%20%20%20beta%2C%0A%20%20%20%20bw0%2C%0A%20%20%20%20c0%2C%0A%20%20%20%20dT%2C%0A%20%20%20%20d_foil%2C%0A%20%20%20%20f%2C%0A%20%20%20%20fix_var%2C%0A%20%20%20%20hw0%2C%0A%20%20%20%20kCu%2C%0A%20%20%20%20k_phi%2C%0A%20%20%20%20ka%2C%0A%20%20%20%20kf%2C%0A%20%20%20%20m_layers%2C%0A%20%20%20%20math%2C%0A%20%20%20%20mon%2C%0A%20%20%20%20mu%2C%0A%20%20%20%20mu0%2C%0A%20%20%20%20n%2C%0A%20%20%20%20pf%2C%0A%20%20%20%20rf%2C%0A%20%20%20%20rho_c%2C%0A%20%20%20%20rho_w%2C%0A%20%20%20%20t0%2C%0A)%3A%0A%20%20%20%20gp%20%3D%20GeometricProgramming(28%2C%20n%2C%20verbose%3DTrue)%0A%0A%20%20%20%20%23%20Objective%3A%20minimize%20total%20loss%20(HF%20minimum-loss%20design)%0A%20%20%20%20gp.addObjective(%5B%0A%20%20%20%20%20%20%20%20mon(1.0%2C%20%7B%22Pcbar%22%3A%201%7D)%2C%0A%20%20%20%20%20%20%20%20mon(1.0%2C%20%7B%22Pcubar%22%3A%201%7D)%2C%0A%20%20%20%20%20%20%20%20%5D)%0A%0A%20%20%20%20k%20%3D%200%0A%20%20%20%20%23%20---%20Fixed%20core%20dimensions%20for%20HF%20minimum-loss%20design%20(held%20fixed)%0A%20%20%20%20k%20%3D%20fix_var(gp%2C%20k%2C%20%22c%22%2C%20%20c0)%0A%20%20%20%20k%20%3D%20fix_var(gp%2C%20k%2C%20%22t%22%2C%20%20t0)%0A%20%20%20%20k%20%3D%20fix_var(gp%2C%20k%2C%20%22bw%22%2C%20bw0)%0A%20%20%20%20k%20%3D%20fix_var(gp%2C%20k%2C%20%22hw%22%2C%20hw0)%0A%0A%20%20%20%20%23%20(33)%0A%20%20%20%20k%20%3D%20add_eq_as_two_ineq(%0A%20%20%20%20%20%20%20%20gp%2C%20k%2C%0A%20%20%20%20%20%20%20%20(2.0**1.5)*math.pi*f*kf*(Ep**-1.0)%2C%0A%20%20%20%20%20%20%20%20%7B%22Np%22%3A1%2C%22B%22%3A1%2C%22c%22%3A1%2C%22t%22%3A1%7D%0A%20%20%20%20)%0A%0A%20%20%20%20%23%20(34)%0A%20%20%20%20k%20%3D%20add_eq_as_two_ineq(%0A%20%20%20%20%20%20%20%20gp%2C%20k%2C%0A%20%20%20%20%20%20%20%20Es*(Ep**-1.0)%2C%0A%20%20%20%20%20%20%20%20%7B%22Np%22%3A1%2C%22Ns%22%3A-1%7D%0A%20%20%20%20)%0A%0A%20%20%20%20%23%20(35)%0A%20%20%20%20k%20%3D%20add_eq_as_two_ineq(%0A%20%20%20%20%20%20%20%20gp%2C%20k%2C%0A%20%20%20%20%20%20%20%202.0*(kCu**-1.0)*Ip%2C%0A%20%20%20%20%20%20%20%20%7B%22Np%22%3A1%2C%22J%22%3A-1%2C%22bw%22%3A-1%2C%22hw%22%3A-1%7D%0A%20%20%20%20)%0A%0A%0A%20%20%20%20%23%20(36)%0A%20%20%20%20k%20%3D%20add_eq_as_two_ineq(%0A%20%20%20%20%20%20%20%20gp%2C%20k%2C%0A%20%20%20%20%20%20%20%20(Fl**-1.0)*(d_foil**-1.0)*Ip%2C%0A%20%20%20%20%20%20%20%20%7B%22J%22%3A-1%2C%22Np%22%3A1%2C%22Ns%22%3A-1%2C%22Nls%22%3A1%2C%22hw%22%3A-1%7D%0A%20%20%20%20)%0A%0A%20%20%20%20%23%20---%20(37)%20temperature%20rise%0A%20%20%20%20denom_T%20%3D%201.42*math.sqrt(2.0)*ka*(dT**(5%2F4))%0A%20%20%20%20gp.addConstraint(k%2C%20%5B%0A%20%20%20%20%20%20%20%20mon(1.0%2Fdenom_T%2C%20%7B%22Pcbar%22%3A1%2C%22hbar%22%3A0.25%2C%22c%22%3A-0.5%2C%22t%22%3A-0.5%2C%22bw%22%3A-0.5%2C%22hw%22%3A-0.5%7D)%2C%0A%20%20%20%20%20%20%20%20mon(1.0%2Fdenom_T%2C%20%7B%22Pcubar%22%3A1%2C%22hbar%22%3A0.25%2C%22c%22%3A-0.5%2C%22t%22%3A-0.5%2C%22bw%22%3A-0.5%2C%22hw%22%3A-0.5%7D)%2C%0A%20%20%20%20%5D)%3B%20k%20%2B%3D%201%0A%0A%20%20%20%20%23%20---%20(38)%20hw%20%2B%202c%20%3C%3D%20hbar%0A%20%20%20%20gp.addConstraint(k%2C%20%5B%0A%20%20%20%20%20%20%20%20mon(1.0%2C%20%7B%22hw%22%3A1%2C%22hbar%22%3A-1%7D)%2C%0A%20%20%20%20%20%20%20%20mon(2.0%2C%20%7B%22c%22%3A1%2C%22hbar%22%3A-1%7D)%2C%0A%20%20%20%20%5D)%3B%20k%20%2B%3D%201%0A%0A%20%20%20%20%23%20---%20(39)%20core%20loss%20upper%20bound%0A%20%20%20%20Ccore%20%3D%20kf%20*%20Kc%20*%20rho_c%20*%20(f%20**%20alpha)%0A%20%20%20%20gp.addConstraint(k%2C%20%5B%0A%20%20%20%20%20%20%20%20mon(4.0%20*%20Ccore%2C%20%7B%22B%22%3A%20beta%2C%20%22c%22%3A%201%2C%20%22t%22%3A%201%2C%20%22hw%22%3A%201%2C%20%22Pcbar%22%3A%20-1%7D)%2C%0A%20%20%20%20%20%20%20%20mon(8.0%20*%20Ccore%2C%20%7B%22B%22%3A%20beta%2C%20%22c%22%3A%202%2C%20%22t%22%3A%201%2C%20%22Pcbar%22%3A%20-1%7D)%2C%0A%20%20%20%20%20%20%20%20mon(4.0%20*%20Ccore%2C%20%7B%22B%22%3A%20beta%2C%20%22c%22%3A%201%2C%20%22t%22%3A%201%2C%20%22bw%22%3A%201%2C%20%22Pcbar%22%3A%20-1%7D)%2C%0A%20%20%20%20%5D)%3B%20k%20%2B%3D%201%0A%0A%0A%20%20%20%20%23%20---%20(40)%20copper%20loss%20upper%20bound%0A%20%20%20%20Ccu%20%3D%20kCu*Fr*rho_w%0A%20%20%20%20gp.addConstraint(k%2C%20%5B%0A%20%20%20%20%20%20%20%20mon(4.0*Ccu%2C%20%7B%22c%22%3A1%2C%22bw%22%3A1%2C%22hw%22%3A1%2C%22J%22%3A2%2C%22Pcubar%22%3A-1%7D)%2C%0A%20%20%20%20%20%20%20%20mon(2.0*Ccu%2C%20%7B%22t%22%3A1%2C%22bw%22%3A1%2C%22hw%22%3A1%2C%22J%22%3A2%2C%22Pcubar%22%3A-1%7D)%2C%0A%20%20%20%20%20%20%20%20mon(math.pi*Ccu%2C%20%7B%22bw%22%3A2%2C%22hw%22%3A1%2C%22J%22%3A2%2C%22Pcubar%22%3A-1%7D)%2C%0A%20%20%20%20%5D)%3B%20k%20%2B%3D%201%0A%0A%20%20%20%20%23%20%23%20---%20(41)%20efficiency%0A%20%20%20%20%23%20coeff_eta%20%3D%20eta_m%2F((1.0-eta_m)*Po)%0A%20%20%20%20%23%20gp.addConstraint(k%2C%20%5B%0A%20%20%20%20%23%20%20%20%20%20mon(coeff_eta%2C%20%7B%22Pcubar%22%3A1%7D)%2C%0A%20%20%20%20%23%20%20%20%20%20mon(coeff_eta%2C%20%7B%22Pcbar%22%3A1%7D)%2C%0A%20%20%20%20%23%20%5D)%3B%20k%20%2B%3D%201%0A%0A%20%20%20%20%23%20---%20(42)%20magnetizing%20current%0A%20%20%20%20CIm%20%3D%20math.sqrt(2.0)%2Fmu%0A%20%20%20%20gp.addConstraint(k%2C%20%5B%0A%20%20%20%20%20%20%20%20mon(CIm%2C%20%7B%22B%22%3A1%2C%22Np%22%3A-1%2C%22hw%22%3A1%2C%22Imbar%22%3A-1%7D)%2C%0A%20%20%20%20%20%20%20%20mon(CIm%2C%20%7B%22B%22%3A1%2C%22Np%22%3A-1%2C%22bw%22%3A1%2C%22Imbar%22%3A-1%7D)%2C%0A%20%20%20%20%20%20%20%20mon(2.0*CIm%2C%20%7B%22B%22%3A1%2C%22Np%22%3A-1%2C%22c%22%3A1%2C%22Imbar%22%3A-1%7D)%2C%0A%20%20%20%20%5D)%3B%20k%20%2B%3D%201%0A%0A%20%20%20%20%23%20---%20(43)%20saturation%0A%20%20%20%20gp.addConstraint(k%2C%20%5Bmon(Bsat**-1.0%2C%20%7B%22B%22%3A1%7D)%5D)%3B%20k%20%2B%3D%201%0A%0A%20%20%20%20%23%20---%20(44)%20no-load%20current%20ratio%0A%20%20%20%20Cnl%20%3D%20(k_phi**-2.0)*(Ip**-2.0)%0A%20%20%20%20gp.addConstraint(k%2C%20%5B%0A%20%20%20%20%20%20%20%20mon(Cnl%2C%20%7B%22Imbar%22%3A2%7D)%2C%0A%20%20%20%20%20%20%20%20mon(Cnl*(Ep**-2.0)%2C%20%7B%22Pcbar%22%3A2%7D)%2C%0A%20%20%20%20%5D)%3B%20k%20%2B%3D%201%0A%0A%0A%20%20%20%20%23%20---%20(45)%20resistive%20regulation%0A%20%20%20%20Cr%20%3D%20Fr*rho_w*pf%0A%20%20%20%20gp.addConstraint(k%2C%20%5B%0A%20%20%20%20%20%20%20%20mon(8.0*Cr%2C%20%7B%22Np%22%3A1%2C%22c%22%3A1%2C%22J%22%3A1%2C%22VRrbar%22%3A-1%7D)%2C%0A%20%20%20%20%20%20%20%20mon(4.0*Cr%2C%20%7B%22Np%22%3A1%2C%22t%22%3A1%2C%22J%22%3A1%2C%22VRrbar%22%3A-1%7D)%2C%0A%20%20%20%20%20%20%20%20mon(2.0*math.pi*Cr%2C%20%7B%22Np%22%3A1%2C%22bw%22%3A1%2C%22J%22%3A1%2C%22VRrbar%22%3A-1%7D)%2C%0A%20%20%20%20%5D)%3B%20k%20%2B%3D%201%0A%0A%20%20%20%20%23%20---%20(46)%20reactive%20regulation%20(substitute%20p%20%3D%202Ns%2F(m*Nls))%0A%20%20%20%20inv_p2%20%3D%20(m_layers**2)%2F4.0%0A%20%20%20%20Cx%20%3D%20Ip*rf*f*mu0*inv_p2%0A%20%20%20%20gp.addConstraint(k%2C%20%5B%0A%20%20%20%20%20%20%20%20mon((8.0*math.pi%2F3.0)*Cx%2C%20%7B%22Np%22%3A2%2C%22c%22%3A1%2C%22bw%22%3A1%2C%22hw%22%3A-1%2C%22VRxbar%22%3A-1%2C%22Nls%22%3A2%2C%22Ns%22%3A-2%7D)%2C%0A%20%20%20%20%20%20%20%20mon((4.0*math.pi%2F3.0)*Cx%2C%20%7B%22Np%22%3A2%2C%22t%22%3A1%2C%22bw%22%3A1%2C%22hw%22%3A-1%2C%22VRxbar%22%3A-1%2C%22Nls%22%3A2%2C%22Ns%22%3A-2%7D)%2C%0A%20%20%20%20%20%20%20%20mon((2.0*(math.pi**2)%2F3.0)*Cx%2C%20%7B%22Np%22%3A2%2C%22bw%22%3A2%2C%22hw%22%3A-1%2C%22VRxbar%22%3A-1%2C%22Nls%22%3A2%2C%22Ns%22%3A-2%7D)%2C%0A%20%20%20%20%5D)%3B%20k%20%2B%3D%201%0A%0A%20%20%20%20%23%20---%20(47)%20Nls%20%3E%3D%201%20and%20Ns%20%3E%3D%20m*Nls%0A%20%20%20%20gp.addConstraint(k%2C%20%5Bmon(1.0%2C%20%7B%22Nls%22%3A-1%7D)%5D)%3B%20k%20%2B%3D%201%0A%20%20%20%20gp.addConstraint(k%2C%20%5Bmon(float(m_layers)%2C%20%7B%22Nls%22%3A1%2C%22Ns%22%3A-1%7D)%5D)%3B%20k%20%2B%3D%201%0A%0A%20%20%20%20%23%20---%20(48)%20total%20regulation%0A%20%20%20%20coeff_vr%20%3D%20(Ep**-1.0)*(VRm**-1.0)%0A%20%20%20%20gp.addConstraint(k%2C%20%5B%0A%20%20%20%20%20%20%20%20mon(coeff_vr%2C%20%7B%22VRrbar%22%3A1%7D)%2C%0A%20%20%20%20%20%20%20%20mon(coeff_vr%2C%20%7B%22VRxbar%22%3A1%7D)%2C%0A%20%20%20%20%5D)%3B%20k%20%2B%3D%201%0A%0A%20%20%20%20%23%20gp.printModel()%0A%20%20%20%20return%20(gp%2C)%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%20Solve%20the%20model%20using%20%60Solve()%60%20function.%20This%20function%20takes%20input%20of%20the%20desired%20log%20file%20location%20and%20name.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(gp)%3A%0A%20%20%20%20sol%2C%20x_vals%2C%20iterations%2C%20elapsedTime%20%3D%20gp.Solve(%22xfmr_min_mass%22)%0A%20%20%20%20return%20elapsedTime%2C%20iterations%2C%20x_vals%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%20Extract%20the%20decision%20variable%20values.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20Es%2C%0A%20%20%20%20Ip%2C%0A%20%20%20%20S%2C%0A%20%20%20%20bw0%2C%0A%20%20%20%20c0%2C%0A%20%20%20%20elapsedTime%2C%0A%20%20%20%20hw0%2C%0A%20%20%20%20iterations%2C%0A%20%20%20%20kCu%2C%0A%20%20%20%20kf%2C%0A%20%20%20%20m_layers%2C%0A%20%20%20%20math%2C%0A%20%20%20%20pf%2C%0A%20%20%20%20rho_Cu%2C%0A%20%20%20%20rho_c%2C%0A%20%20%20%20t0%2C%0A%20%20%20%20vid%2C%0A%20%20%20%20x_vals%2C%0A)%3A%0A%20%20%20%20%23%20Extract%20GP%20solution%20variables%20%0A%20%20%20%20Np%20%20%3D%20x_vals%5Bvid%5B%22Np%22%5D%5D%0A%20%20%20%20Ns%20%20%3D%20x_vals%5Bvid%5B%22Ns%22%5D%5D%0A%20%20%20%20Nls%20%3D%20x_vals%5Bvid%5B%22Nls%22%5D%5D%0A%20%20%20%20B%20%20%20%3D%20x_vals%5Bvid%5B%22B%22%5D%5D%20%20%20%20%20%20%20%20%23%20T%0A%20%20%20%20J%20%20%20%3D%20x_vals%5Bvid%5B%22J%22%5D%5D%20%20%20%20%20%20%20%20%23%20A%2Fm%5E2%0A%20%20%20%20Pc%20%20%3D%20x_vals%5Bvid%5B%22Pcbar%22%5D%5D%20%20%20%20%23%20W%0A%20%20%20%20Pcu%20%3D%20x_vals%5Bvid%5B%22Pcubar%22%5D%5D%20%20%20%23%20W%0A%0A%20%20%20%20%23%20Fixed%20geometry%20(m)%0A%20%20%20%20c%2C%20t%2C%20bw%2C%20hw%20%3D%20c0%2C%20t0%2C%20bw0%2C%20hw0%0A%0A%20%20%20%20%23%20Geometry%20(cm)%0A%20%20%20%20c_cm%20%20%3D%20c%20*%20100.0%0A%20%20%20%20t_cm%20%20%3D%20t%20*%20100.0%0A%20%20%20%20bw_cm%20%3D%20bw%20*%20100.0%0A%20%20%20%20hw_cm%20%3D%20hw%20*%20100.0%0A%0A%20%20%20%20%23%20Winding%20structure%0A%20%20%20%20p_val%20%3D%202.0%20*%20Ns%20%2F%20(m_layers%20*%20Nls)%0A%0A%20%20%20%20%23%20Currents%0A%20%20%20%20Ip_val%20%3D%20Ip%0A%20%20%20%20Is_val%20%3D%20S%20%2F%20Es%0A%0A%20%20%20%20%23%20Copper%20areas%20(mm%5E2)%0A%20%20%20%20Acu_p_mm2%20%3D%20(Ip_val%20%2F%20J)%20*%201e6%0A%20%20%20%20Acu_s_mm2%20%3D%20(Is_val%20%2F%20J)%20*%201e6%0A%0A%20%20%20%20%23%20Masses%20(kg%20-%20g)%0A%20%20%20%20m_core%20%3D%20(%0A%20%20%20%20%20%20%20%204.0*kf*rho_c%20*%20(c*t*hw)%20%2B%0A%20%20%20%20%20%20%20%208.0*kf*rho_c%20*%20(c**2*t)%20%2B%0A%20%20%20%20%20%20%20%204.0*kf*rho_c%20*%20(c*t*bw)%0A%20%20%20%20)%0A%0A%20%20%20%20m_cu%20%3D%20(%0A%20%20%20%20%20%20%20%204.0*kCu*rho_Cu%20*%20(c*bw*hw)%20%2B%0A%20%20%20%20%20%20%20%202.0*kCu*rho_Cu%20*%20(t*bw*hw)%20%2B%0A%20%20%20%20%20%20%20%20math.pi*kCu*rho_Cu%20*%20(bw**2*hw)%0A%20%20%20%20)%0A%0A%20%20%20%20m_total_g%20%3D%20(m_core%20%2B%20m_cu)%20*%201e3%0A%0A%20%20%20%20%23%20Magnetic%20%2F%20electrical%20quantities%0A%20%20%20%20B_mT%20%20%3D%20B%20*%201e3%0A%20%20%20%20J_mm2%20%3D%20J%20*%201e-6%0A%0A%20%20%20%20%23%20Efficiency%0A%20%20%20%20Po%20%3D%20S%20*%20pf%0A%20%20%20%20eta_pct%20%3D%20100.0%20*%20Po%20%2F%20(Po%20%2B%20Pc%20%2B%20Pcu)%0A%0A%20%20%20%20results%20%3D%20%5B%0A%20%20%20%20%20%20%20%20(%22c%22%2C%20%20%20%20%20%20%20%20c_cm%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22cm%22)%2C%0A%20%20%20%20%20%20%20%20(%22t%22%2C%20%20%20%20%20%20%20%20t_cm%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22cm%22)%2C%0A%20%20%20%20%20%20%20%20(%22bw%22%2C%20%20%20%20%20%20%20bw_cm%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22cm%22)%2C%0A%20%20%20%20%20%20%20%20(%22hw%22%2C%20%20%20%20%20%20%20hw_cm%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22cm%22)%2C%0A%20%20%20%20%20%20%20%20(%22Np%22%2C%20%20%20%20%20%20%20int(round(Np))%2C%20%20%20%20%20%20%20%20%20%20%20%22-%22)%2C%0A%20%20%20%20%20%20%20%20(%22Ns%22%2C%20%20%20%20%20%20%20int(round(Ns))%2C%20%20%20%20%20%20%20%20%20%20%20%22-%22)%2C%0A%20%20%20%20%20%20%20%20(%22Nlp%22%2C%20%20%20%20%20%201%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22-%22)%2C%0A%20%20%20%20%20%20%20%20(%22Nls%22%2C%20%20%20%20%20%20int(round(Nls))%2C%20%20%20%20%20%20%20%20%20%20%22-%22)%2C%0A%20%20%20%20%20%20%20%20(%22p%22%2C%20%20%20%20%20%20%20%20int(round(p_val))%2C%20%20%20%20%20%20%20%20%22-%22)%2C%0A%20%20%20%20%20%20%20%20(%22A_cu%2Cp%22%2C%20%20%20Acu_p_mm2%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22mm%C2%B2%22)%2C%0A%20%20%20%20%20%20%20%20(%22A_cu%2Cs%22%2C%20%20%20Acu_s_mm2%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22mm%C2%B2%22)%2C%0A%20%20%20%20%20%20%20%20(%22m_c%22%2C%20%20%20%20%20%20m_core%20*%201e3%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%22g%22)%2C%0A%20%20%20%20%20%20%20%20(%22m_cu%22%2C%20%20%20%20%20m_cu%20*%201e3%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22g%22)%2C%0A%20%20%20%20%20%20%20%20(%22m_c%2Bm_cu%22%2C%20m_total_g%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22g%22)%2C%0A%20%20%20%20%20%20%20%20(%22B%22%2C%20%20%20%20%20%20%20%20B_mT%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22mT%22)%2C%0A%20%20%20%20%20%20%20%20(%22J%22%2C%20%20%20%20%20%20%20%20J_mm2%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22A%2Fmm%C2%B2%22)%2C%0A%20%20%20%20%20%20%20%20(%22Pc%22%2C%20%20%20%20%20%20%20Pc%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22W%22)%2C%0A%20%20%20%20%20%20%20%20(%22Pcu%22%2C%20%20%20%20%20%20Pcu%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22W%22)%2C%0A%20%20%20%20%20%20%20%20(%22%CE%B7%22%2C%20%20%20%20%20%20%20%20eta_pct%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22%25%22)%2C%0A%0A%20%20%20%20%20%20%20%20%23%20----%20separator%20----%0A%20%20%20%20%20%20%20%20(%22__SEP__%22%2C%20%20None%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20None)%2C%0A%0A%20%20%20%20%20%20%20%20%23%20----%20solver%20stats%20----%0A%20%20%20%20%20%20%20%20(%22Iterations%22%2C%20%20iterations%2C%20%20%20%20%20%20%20%20%20%20%20%20%22%22)%2C%0A%20%20%20%20%20%20%20%20(%22Elapsed%20time%22%2C%20elapsedTime%2C%20%20%20%20%20%20%20%20%20%20%20%22s%22)%2C%0A%20%20%20%20%5D%0A%20%20%20%20return%20(results%2C)%0A%0A%0A%40app.function(hide_code%3DTrue)%0Adef%20print_table(results%2C%20title%3D%22Summary%22)%3A%0A%20%20%20%20q_w%2C%20v_w%2C%20u_w%20%3D%2014%2C%2012%2C%208%0A%20%20%20%20total%20%3D%20q_w%20%2B%201%20%2B%20v_w%20%2B%201%20%2B%20u_w%0A%0A%20%20%20%20def%20hline(ch%3D%22%E2%94%80%22)%3A%0A%20%20%20%20%20%20%20%20print(ch%20*%20total)%0A%0A%20%20%20%20print(title)%0A%20%20%20%20hline(%22%E2%95%90%22)%0A%20%20%20%20print(f%22%7B'Quantity'%3A%3C%7Bq_w%7D%7D%20%7B'Value'%3A%3E%7Bv_w%7D%7D%20%7B'Unit'%3A%3E%7Bu_w%7D%7D%22)%0A%20%20%20%20hline(%22%E2%94%80%22)%0A%0A%20%20%20%20for%20q%2C%20v%2C%20u%20in%20results%3A%0A%20%20%20%20%20%20%20%20if%20q%20%3D%3D%20%22__SEP__%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20hline(%22%E2%94%80%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20continue%0A%0A%20%20%20%20%20%20%20%20%23%20Format%20numbers%0A%20%20%20%20%20%20%20%20if%20isinstance(v%2C%20float)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20u%20%3D%3D%20%22s%22%3A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20time%20%E2%86%92%203%20decimals%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20v_str%20%3D%20f%22%7Bv%3A.3f%7D%22%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20everything%20else%20%E2%86%92%202%20decimals%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20v_str%20%3D%20f%22%7Bv%3A%2C.2f%7D%22%0A%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20v_str%20%3D%20str(v)%0A%0A%20%20%20%20%20%20%20%20u_str%20%3D%20%22%22%20if%20u%20is%20None%20else%20str(u)%0A%20%20%20%20%20%20%20%20print(f%22%7Bq%3A%3C%7Bq_w%7D%7D%20%7Bv_str%3A%3E%7Bv_w%7D%7D%20%7Bu_str%3A%3E%7Bu_w%7D%7D%22)%0A%0A%20%20%20%20hline(%22%E2%95%90%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%20The%20following%20table%20displays%20the%20resulting%20values%20of%20Transformer%20Design%20at%20100%20kHz.%20The%20values%20follow%20the%20values%20showed%20in%20the%20paper%20at%20Table%202.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(results)%3A%0A%20%20%20%20print_table(results%2C%20title%3D%22Transformer%20design%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%20Appendix%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%20import%20numpy%20as%20np%0A%20%20%20%20from%20mosek.fusion%20import%20Model%2C%20Domain%2C%20Expr%2C%20ObjectiveSense%0A%20%20%20%20import%20mosek.fusion.pythonic%0A%20%20%20%20import%20math%0A%0A%20%20%20%20class%20Monomial%3A%0A%20%20%20%20%20%20%20%20def%20__init__(self%2C%20coefficient%3DNone%2C%20indices%3DNone%2C%20alphas%3DNone%2C%20n%3DNone)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20self.coefficient%20%3D%20coefficient%0A%20%20%20%20%20%20%20%20%20%20%20%20self.indices%20%3D%20indices%0A%20%20%20%20%20%20%20%20%20%20%20%20self.alphas%20%3D%20%5B0%5D%20*%20n%20if%20n%20is%20not%20None%20else%20None%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20indices%20is%20not%20None%20and%20alphas%20is%20not%20None%20and%20n%20is%20not%20None%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20idx%2C%20alpha%20in%20zip(indices%2C%20alphas)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20self.alphas%5Bidx%5D%20%3D%20alpha%0A%0A%20%20%20%20%20%20%20%20%40classmethod%0A%20%20%20%20%20%20%20%20def%20add(cls%2C%20coefficient%2C%20indices%2C%20alphas)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20obj%20%3D%20cls(coefficient%3Dcoefficient%2C%20indices%3Dindices%2C%20alphas%3DNone)%0A%20%20%20%20%20%20%20%20%20%20%20%20obj.indices_alphas%20%3D%20alphas%20%20%23%20Store%20original%20input%20to%20reconstruct%20later%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20obj%0A%0A%20%20%20%20%20%20%20%20def%20defineMonomial(self)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20terms%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20has_coefficient%20%3D%20self.coefficient%20!%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20i%2C%20alpha%20in%20enumerate(self.alphas)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20alpha%20!%3D%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20terms.append(f%22(x_%7Bi%7D%20%5E%20%7Balpha%7D)%22)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20joined%20%3D%20%22%20*%20%22.join(%5Bf%22%7Bself.coefficient%7D%22%20if%20has_coefficient%20else%20%22%22%5D%20%2B%20terms%20if%20has_coefficient%20else%20terms)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20has_coefficient%20or%20len(terms)%20%3E%201%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20f%22(%7Bjoined.strip()%7D)%22%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20joined.strip()%0A%0A%20%20%20%20%20%20%20%20%40staticmethod%0A%20%20%20%20%20%20%20%20def%20definePosynomial(monomials)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20%22%20%2B%20%22.join(%5Bm.defineMonomial()%20for%20m%20in%20monomials%5D)%0A%0A%20%20%20%20class%20GeometricProgramming%3A%0A%20%20%20%20%20%20%20%20def%20__init__(self%2C%20m%2C%20n%2C%20verbose%3DFalse)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20self.m%20%3D%20m%0A%20%20%20%20%20%20%20%20%20%20%20%20self.n%20%3D%20n%0A%20%20%20%20%20%20%20%20%20%20%20%20self.constraintsMonomials%20%3D%20%5B%5B%5D%20for%20_%20in%20range(m)%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20self.objectiveMonomials%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20self.totalMonomials%20%3D%200%0A%20%20%20%20%20%20%20%20%20%20%20%20self.verbose%20%3D%20verbose%0A%0A%20%20%20%20%20%20%20%20def%20_fillAlphas(self%2C%20monomial)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Check%20all%20alphas%20before%20assigning%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20alpha%20in%20monomial.indices_alphas%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20alpha%20%3D%3D%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20raise%20ValueError(f%22Invalid%20alpha%20value%20%7Balpha%7D%3A%20all%20exponents%20must%20be%20non-zero.%22)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Safe%20to%20assign%20now%0A%20%20%20%20%20%20%20%20%20%20%20%20monomial.alphas%20%3D%20%5B0%5D%20*%20self.n%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20idx%2C%20alpha%20in%20zip(monomial.indices%2C%20monomial.indices_alphas)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20monomial.alphas%5Bidx%5D%20%3D%20alpha%0A%0A%20%20%20%20%20%20%20%20def%20_checkDuplicateIndex(self%2Cmonomial)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20seen%20%3D%20set()%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20idx%20in%20monomial.indices%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20idx%20in%20seen%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20raise%20ValueError(%22Input%20indices%20has%20to%20be%20unique.%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20seen.add(idx)%0A%0A%20%20%20%20%20%20%20%20def%20addObjective(self%2C%20monomial)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20isinstance(monomial%2C%20list)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20m%20in%20monomial%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20self.addObjective(m)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20monomial.coefficient%20%3C%3D%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20raise%20ValueError(%22Coefficient%20must%20be%20positive%22)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20self._checkDuplicateIndex(monomial)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20self._fillAlphas(monomial)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20self.objectiveMonomials.append(monomial)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20self.totalMonomials%20%2B%3D%201%0A%0A%20%20%20%20%20%20%20%20def%20addConstraint(self%2C%20index%2C%20monomial)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20index%20%3E%3D%20self.m%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20raise%20ValueError(f%22Constraint%20index%20%7Bindex%7D%20out%20of%20range%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20isinstance(monomial%2C%20list)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20m%20in%20monomial%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20self.addConstraint(index%2C%20m)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20monomial.coefficient%20%3C%3D%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20raise%20ValueError(%22Coefficient%20must%20be%20positive%22)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20self._checkDuplicateIndex(monomial)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20self._fillAlphas(monomial)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20self.totalMonomials%20%2B%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20self.constraintsMonomials%5Bindex%5D.append(monomial)%0A%0A%20%20%20%20%20%20%20%20def%20evaluateObjective(self%2C%20x_values)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20len(x_values)%20!%3D%20self.n%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20raise%20ValueError(f%22x_values%20length%20%7Blen(x_values)%7D%20does%20not%20match%20problem%20dimension%20%7Bself.n%7D%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20objective_val%20%3D%200.0%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20mon%20in%20self.objectiveMonomials%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20term%20%3D%20mon.coefficient%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20i%2C%20alpha%20in%20enumerate(mon.alphas)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20term%20*%3D%20x_values%5Bi%5D%20**%20alpha%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20objective_val%20%2B%3D%20term%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20objective_val%0A%0A%20%20%20%20%20%20%20%20def%20analyse(self)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22---------%20Model%20Analysis%20---------%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22%23%20of%20constraints%3A%20%22%2C%20self.m)%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22%23%20of%20variables%3A%20%22%2C%20self.n)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20all_monomials%20%3D%20self.objectiveMonomials%20%2B%20%5Bm%20for%20sublist%20in%20self.constraintsMonomials%20for%20m%20in%20sublist%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20coefficients%20%3D%20%5Bmon.coefficient%20for%20mon%20in%20all_monomials%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20coefficients%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(f%22Range%20of%20coefficients%3A%20%5B%7Bmin(coefficients)%7D%2C%20%7Bmax(coefficients)%7D%5D%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(%22No%20monomials%20added%20yet.%22)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20all_alphas%20%3D%20%5Babs(alpha)%20for%20mon%20in%20all_monomials%20for%20alpha%20in%20mon.alphas%20if%20alpha%20!%3D%200%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20all_alphas%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(f%22Range%20of%20absolute%20alpha%20values%3A%20%5B%7Bmin(all_alphas)%7D%2C%20%7Bmax(all_alphas)%7D%5D%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(%22No%20alpha%20values%20found.%22)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22Degree%20of%20Difficulty%3A%20%22%2C%20self.totalMonomials%20-%20self.n%20-%201%2C%20%22%5Cn%22)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20i%20in%20range(self.n)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20signs%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20mon%20in%20all_monomials%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%20%3D%20mon.alphas%5Bi%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20alpha%20%3E%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20signs.append(1)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20elif%20alpha%20%3C%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20signs.append(-1)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20signs%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20all(s%20%3E%200%20for%20s%20in%20signs)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(f%22Warning%3A%20Variable%20x_%7Bi%7D%20only%20has%20positive%20exponents%20across%20all%20monomials.%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20elif%20all(s%20%3C%200%20for%20s%20in%20signs)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(f%22Warning%3A%20Variable%20x_%7Bi%7D%20only%20has%20negative%20exponents%20across%20all%20monomials.%22)%0A%0A%20%20%20%20%20%20%20%20def%20printModel(self)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22Objective%20function%3A%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20print(f%22%5CtMinimize%3A%20%7BMonomial.definePosynomial(self.objectiveMonomials)%7D%22)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20any(self.constraintsMonomials)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(%22%5CnConstraints%3A%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20i%2C%20con%20in%20enumerate(self.constraintsMonomials)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20con%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(f%22%5CtConstraint%20%7Bi%2B1%7D%3A%20%7BMonomial.definePosynomial(con)%7D%20%3C%3D%201%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(%22%5CnNo%20constraints%20defined.%22)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22%20%22)%0A%0A%20%20%20%20%20%20%20%20def%20Solve(self%2C%20fileName%3DNone)%3A%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20not%20self.objectiveMonomials%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20raise%20ValueError(%22No%20objective%20monomials%20defined.%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20M%20%3D%20Model()%0A%20%20%20%20%20%20%20%20%20%20%20%20x%20%3D%20M.variable(%22x%22%2C%20self.n)%0A%20%20%20%20%20%20%20%20%20%20%20%20t%20%3D%20M.variable(%22t%22%2C%201)%0A%20%20%20%20%20%20%20%20%20%20%20%20p%20%3D%20M.variable(%22p%22%2C%20self.totalMonomials)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20self.verbose%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20import%20sys%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20M.setLogHandler(sys.stdout)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20currentMonomialIndex%20%3D%200%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Objective%0A%20%20%20%20%20%20%20%20%20%20%20%20dummySum%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20objectiveMonomials%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20noOfMono%20%3D%20len(self.objectiveMonomials)%0A%20%20%20%20%20%20%20%20%20%20%20%20j%20%3D%200%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20noOfMono%20%3E%201%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20mon%20in%20self.objectiveMonomials%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20expr%20%3D%20Expr.dot(mon.alphas%2C%20x.T)%20%2B%20np.log(mon.coefficient)%20-%20t%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20objectiveMonomials.append(expr)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20dummySum.append(p%5BcurrentMonomialIndex%20%2B%20j%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20j%20%2B%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20M.constraint(%22Objective%20Definition%22%2C%20Expr.hstack(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20p.slice(currentMonomialIndex%2C%20currentMonomialIndex%20%2B%20noOfMono)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Expr.ones(noOfMono)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Expr.vstack(objectiveMonomials))%20%3D%3D%20Domain.inPExpCone())%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20M.constraint(%22Objective%20Dummy%20Sum%22%2C%20Expr.sum(Expr.vstack(dummySum))%20%3C%3D%201)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20M.constraint(%22Objective%20Definition%22%2C%20Expr.dot(self.objectiveMonomials%5B0%5D.alphas%2C%20x.T)%20%3C%3D%20t)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20currentMonomialIndex%20%2B%3D%20noOfMono%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Constraints%20(only%20if%20defined)%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20i%2C%20monomials%20in%20enumerate(self.constraintsMonomials)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20not%20monomials%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20continue%20%20%23%20Skip%20empty%20constraint%20slots%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20noOfMono%20%3D%20len(monomials)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20constraintMonomials%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20dummySum%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20j%20%3D%200%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20noOfMono%20%3E%201%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20mon%20in%20monomials%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20expr%20%3D%20Expr.dot(mon.alphas%2C%20x.T)%20%2B%20np.log(mon.coefficient)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20constraintMonomials.append(expr)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20dummySum.append(p%5BcurrentMonomialIndex%20%2B%20j%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20j%20%2B%3D%201%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20M.constraint(%22Conic-Constraint%20Definition%22%20%2B%20str(i)%2C%20Expr.hstack(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20p.slice(currentMonomialIndex%2C%20currentMonomialIndex%20%2B%20noOfMono)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Expr.ones(noOfMono)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Expr.vstack(constraintMonomials))%20%3D%3D%20Domain.inPExpCone())%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20M.constraint(%22Constraint%20Dummy%20Sum%22%20%2B%20str(i)%2C%20Expr.sum(Expr.vstack(dummySum))%20%3C%3D%201)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20M.constraint(%22Constraint%20Definition%22%20%2B%20str(i)%2C%20Expr.dot(monomials%5B0%5D.alphas%2C%20x.T)%20%2B%20np.log(monomials%5B0%5D.coefficient)%20%3C%3D%200)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20currentMonomialIndex%20%2B%3D%20noOfMono%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20M.objective(%22Objective%20Function%22%2C%20ObjectiveSense.Minimize%2C%20t)%0A%20%20%20%20%20%20%20%20%20%20%20%20M.solve()%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20fileName%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20M.writeTask(fileName%20%2B%20%22.ptf%22)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20ModelStatus%20%3D%20M.getPrimalSolutionStatus()%0A%20%20%20%20%20%20%20%20%20%20%20%20ProblemStatus%20%3D%20M.getProblemStatus()%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20ModelStatus%20%3D%3D%20mosek.fusion.pythonic.SolutionStatus.Optimal%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20sol%20%3D%20x.level()%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20vars%20%3D%20np.exp(sol)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(%22Model%20Status%3A%20Optimal%22)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20sol%20%3D%20None%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20vars%20%3D%20None%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(%22The%20problem%20does%20not%20have%20an%20optimal%20solution.%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(%22Problem%20Status%3A%20%22%2C%20ProblemStatus)%0A%20%20%20%20%20%20%20%20%20%20%20%20t%20%3D%20M.getSolverDoubleInfo(%22optimizerTime%22)%20%20%23%20seconds%0A%20%20%20%20%20%20%20%20%20%20%20%20num_iter%20%3D%20M.getSolverIntInfo(%22intpntIter%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20sol%2C%20vars%2C%20num_iter%2C%20t%0A%20%20%20%20return%20GeometricProgramming%2C%20Monomial%2C%20math%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%3Ca%20rel%3D%22license%22%20href%3D%22http%3A%2F%2Fcreativecommons.org%2Flicenses%2Fby%2F4.0%2F%22%3E%3Cimg%20alt%3D%22Creative%20Commons%20License%22%20style%3D%22border-width%3A0%22%20src%3D%22https%3A%2F%2Fi.creativecommons.org%2Fl%2Fby%2F4.0%2F80x15.png%22%20%2F%3E%3C%2Fa%3E%3Cbr%20%2F%3EThis%20work%20is%20licensed%20under%20a%20%3Ca%20rel%3D%22license%22%20href%3D%22http%3A%2F%2Fcreativecommons.org%2Flicenses%2Fby%2F4.0%2F%22%3ECreative%20Commons%20Attribution%204.0%20International%20License%3C%2Fa%3E.%20The%20**MOSEK**%20logo%20and%20name%20are%20trademarks%20of%20%3Ca%20href%3D%22http%3A%2F%2Fmosek.com%22%3EMosek%20ApS%3C%2Fa%3E.%20The%20code%20is%20provided%20as-is.%20Compatibility%20with%20future%20release%20of%20**MOSEK**%20or%20the%20%60Fusion%20API%60%20are%20not%20guaranteed.%20For%20more%20information%20contact%20our%20%5Bsupport%5D(mailto%3Asupport%40mosek.com).%0A%20%20%20%20%22%22%22)%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
3c4f58497c2761a1bc45932e2a44f351