# Copyright (c) 2026 JSOL CORPORATION # # This script is released under the MIT License. # See the full license text at: # https://www.jmag-international.com/scriptlibrary/jmag_script_library_mit/ app = designer.GetApplication() def paramItemModifyMinMaxValRange(optTbl, paramDataArray): """Setting parameter variable ranges in optimization, and selecting dimension variables whose ranges to modify.""" optTbl.SetParameter(u"engine", u"jsol_moga") optTbl.SetParameter(u"jsol_moga_use_range_optimization", True) optTbl.SetParameter(u"jsol_moga_use_automatic_parameters_in_range_optimization", True) optTbl.SetParameter(u"jsol_moga_expand_range_search", True) for paramName, minVal, maxVal, minFlag, maxFlag in paramDataArray: optTbl.SetCheckOn(paramName, True) paramItem = optTbl.GetParametricItem(paramName) paramItem.SetMin(minVal) paramItem.SetMax(maxVal) # Select the dimension variable to modify the range. if minFlag: paramItem.SetModifyMinValueRange(minFlag) if maxFlag: paramItem.SetModifyMaxValueRange(maxFlag) study = app.GetCurrentStudy() optTbl = study.GetOptimizationTable() paramDataArray = [ # Parameter name, parameter minimum value, parameter maximum value, whether to search the dimension range for the minimum value, whether to search the dimension range for the maximum value. [u"CS1 (3PhaseCurrentSource): PhaseU", 0, 70, None, None], [u"CAD parameters: FBCenterWidth0@Variables", 0.5, 6, True, False], [u"CAD parameters: Flux_In2_deg@Variables", 40, 120, False, True], [u"CAD parameters: Flux_Out1_deg@Variables", 55, 115, False, False], [u"CAD parameters: Flux_Out2_deg@Variables", 45, 125, True, True], ] paramItemModifyMinMaxValRange(optTbl, paramDataArray)