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.