[Wish] Data dam that opens when solver has converged

Is it possible to limit the data flow while the Kangaroo solver is running? I have some relatively heavy operations that I perform on the solver’s result, adding a automatically opening and closing datadam would help in streamlining my script.

Yea that would be awesome. A Boolean (True = Converged) would be enough.

Although the ZombieSolver only passes data on when converged - without the visual iteration feedback.

You can’t pause it, meaning you can’t decide that the result is good enough to pass data onwards.

Hi @Intuos and @rudolf.neumerkel

Here’s an example showing a way to get the component state now

The problem with just a boolean output is that it won’t stop the downstream parts from updating.
Even if a value isn’t changing, if Kangaroo is refreshing as it solves it will trigger updates of everything connected to its outputs.
I think for this to be useful we’d also need a version of the data dam with a boolean input.

1 Like

Yeah, what I think would be best is, since you need to refresh the solver anyways before starting, the reset and on input values could then also be fed into the datadam, which is only triggered once the solver stops (converged) or is paused (by the user).

I often do something like this when I have extremely heavy calculations to do after the solver:

it’s not automatically, but at least it speeds up the entire process.

1 Like

I have now added a data dam with a 10s interval, will see how that goes/ scales the more data I feed into it. May have to add another data dam to get to a 20s interval.

Anemone ‘Classic’ Loop End has a right-click option to “Output after the last”.

Anemone ‘Fast’ doesn’t even have that option, it always works that way.

Yo guyz!

toggable Dam

toggable Dam V0.1.gh (5.0 KB)

Maybe mix this with the boolean from Daniel’s script …


Note that, the “disconnecting event” occours after the wrong data flows, once.
So, you might want to filter that single “wrong impulse” like this:
toggable Dam fix


Code:

  private void RunScript(DataTree<object> Target, DataTree<object> Source, bool G)
  {
    if(!(G & oldstate == 1) || (!G & oldstate == 0)){
      if(G){oldstate = 1;}
      else{oldstate = 0;}
      source = this.Component.Params.Input[1].Sources[0];
      target = this.Component.Params.Input[0].Sources[0];
      this.GrasshopperDocument.ScheduleSolution(5, SolutionCallback);
    }
  }

  // <Custom additional code> 
  int oldstate = -1;
  Grasshopper.Kernel.IGH_Param source;
  Grasshopper.Kernel.IGH_Param target;
  private void SolutionCallback(GH_Document document){
    if(oldstate == 1)target.AddSource(source);
    if(oldstate == 0)target.RemoveSource(source);
  }
6 Likes

Very nice!
Thanks for sharing this

Here’s a test - first with this toggled dam, then without for comparison

toggable Dam V0.1_test.gh (20.9 KB)

4 Likes

Nice, with the topic link in a panel :slight_smile: