Electronics

Electronics

Topics related to HFSS, Maxwell, SIwave, Icepak, Electronics Enterprise and more.

Scripting: Is there a way to delete intermediary iteration results after optimization?

    • AndyJP
      Subscriber

      I am making multiport sequential optimizations in a script where per-port matching are interleaved with inter-port matchings, untill the perfect solution is found.

      The problem is that every optimization setup I execute in my script has solutions stored for 20-30 iterations of search. So the amount of S-parameters data stored grows like a snowball. And it impacts performance actually, making plotting the data difficult the same time.


      Is there an approach of deleting the intermediary data after an optimization setup was completed, but only for that last setup execution(keeping previous good results), excluding the final(good) result?

      Like, getting the id's of every optimetrics iteration in the last run, and finding which one was the last solution to exclude from the list? Are there id's or sequential numbers at all?


      (I use VBS in 2021R1)

    • Praneeth
      Forum Moderator

      Please go through the "HFSS scripting guide" for the available commands that are supported.
      Best regards
    • AndyJP
      Subscriber
      well, my eyes may be weak, but I did not find a way.
      If you are talking about deletefullvariation, it searches for particular parameters. But in the optimization I do not know those from the script. I need some variation iterator, or index, or a timestamp... I don't know, for determining which variations to delete between previous and the last data registered as good.
    • AndyJP
      Subscriber
      technically, if deletefullvariation had an option to delete all variations with incomplete parameter list matching, EXCLUDING the last one, like in the GUI, that would solve my problem. But it deletes either a single specific variation, or "all" the data collected.
    • AndyJP
      Subscriber
      up, seriously. this overload with useless iterations data slows up my parametric searches.
    • AndyJP
      Subscriber
      No, really, there is no explanation in the manual, how to delete some specific variations basing on any kind of selection.
      ListVariations and similar commands are also not explained. Any attempt to use them results in "no such property or method", or "the command requires " ", or "cannot use ( in the sub".... nonsense. Error messages unintelligible, not letting figure the command use via trial. And the command use is totally obscure.
    • AndyJP
      Subscriber
      So, lets narrow down the question:
      Input: After many iterations, the design oDesign solutions contain a number of variations with main parameters of interest "$Hi" and "$M"
      Required: Delete all the variations with "$Hi"="500" and "$M"="1750".

      How should the VBS code look?
    • AndyJP
      Subscriber
      it is still actual because the manual does not give any hint.
    • AndyJP
      Subscriber
      Every separate results profile text file contains a detailed timestamp, like
      $begin 'ProfileGroup'
      MajorVer=2021
      MinorVer=1
      Name='Initialization'
      StartInfo='Time:08/25/2021 12:44:43'
      ...
      Why is it not possible using it as a feature for managing results conditionally from HFSS/Maxwell?
      Or is it possible?
    • AndyJP
      Subscriber
      I found newer "Electronics Desktop Scripting Guide", which contains some new methods, not listed in "HFSS scripting guide" you had mentioned.
      Particularly oModule.ListMatchingVariations
      After hitting the wall countless times, by trial I found the non-mentioned prerequisite that oModule should be set to oDesign.GetModule("Solutions") !!!! No other module has that method inherited!
      But then again, it does not allow excluding specific variations (last good variation) from the list because:
      Methods
      oModule.ListMatchingVariations("Setup1 : LastAdaptive",("Var"), ("value"))
      and
      oDesign.GetNominalVariation()
      return different set (and order ?) of variables in string format, making them non-comparable.

      Methods
      oDesign.GetVariationVariableValue(list(i), "Var")
      and
      oDesign.GetVariableValue("Var")
      return Var values in different format, with units applied, and without units; making them non-comparable again!

      Why the **** is there no simple unit-aware comparison method?
      Why the data stamp is not returned for variations?
      Is there another undocumented set of functions/methods I should know?

    • AndyJP
      Subscriber
      seems like calling ListMatchingVariations results in standard string() function overloaded by something else.

      In VBS, there is a way of defining repeating symbols in a string by s_var=string( int(count), "s"). But after calling ListMatchingVariations, this line throws an error of wrong type. It was never throwing an error before for me, until I implemented data cleaning by the list.
    • AndyJP
      Subscriber
      I guess, the above was again unexpected change of types by VBS...
    • AndyJP
      Subscriber
      For those who want to remove unwanted iterations:
      This method may still delete the last iteration by mistake since values are converted to unitless Si base values, and there may be inequality in floating point format.... but in most cases it works:
      if oDesign.GetVariableValue("STOP_CALC")<>"0" then Wscript.Quit 'used to stop the script since stopping optimetrics does not forward the stop signal to the interpreter, like sweep does. Wscript.Quit is a VB command not working in VBS, but it still does the thing.

      current=oDesign.GetNominalVariation() 'gets current variables set
      set oModule = oDesign.GetModule("Solutions") 'only Solutions (not Results and not Optimetrics) module has methods for working with results collection.
      list = oModule.ListMatchingVariations("Setup1 : LastAdaptive",(Param1_name,Param2_name), (CStr(Param1_val)&Param1_unit,CStr(Param2_val)&Param2_unit)) 'get a list of variations with properties uniquely matching the last optimization set.
      oDesktop.AddMessage oProject.GetName(), oDesign.GetName(), 0, "================ Deleting optimization temp data ... ===============" 'just a way of logging a custom message
      for i=0 to Ubound(list)
      if (oDesign.GetVariationVariableValue(list(i), "var1")<> oDesign.GetVariationVariableValue(current, "var1")) _ 'when optimizing 4 parameters, in the end the optimizer rewrites the design values with the best result. So prevent deleting it by comparing with current values.
      OR (oDesign.GetVariationVariableValue(list(i), "var2")<> oDesign.GetVariationVariableValue(current, "var2")) _
      OR (oDesign.GetVariationVariableValue(list(i), "var3")<> oDesign.GetVariationVariableValue(current, "var3")) _
      OR (oDesign.GetVariationVariableValue(list(i), "var4")<> oDesign.GetVariationVariableValue(current, "var4")) then
      oDesign.DeleteFullVariation list(i), true
      end if
      next
      Set oModule = oDesign.GetModule("AnalysisSetup") 'set the handling object back to useful module.
      This method is veeery slow since A) VBS is restricted on various array methods and managing functions, and arrays declared in different way are not the same. Particularly, there is no simple way of declaring a (VC++ vector() style) dynamic array and allowing to clear it in the loop. It is either not truly dynamic, or Erase does not work. So you have to sweep the collection two times for resizing arrays explicitly; it works not so good in interpreter level "basic" languages .
      So it is not easy makign a guaranteed list of variations to delete at once; deleting one by one is safer.

      If you have other suggestions, or know how to make a safer guaranteed comparison, or prepare the delete list with excluded results at once, please share.
Viewing 12 reply threads
  • The topic ‘Scripting: Is there a way to delete intermediary iteration results after optimization?’ is closed to new replies.