Grasshopper

algorithmic modeling for Rhino

Could be possible to code a genome list that uses inputs to generate that list? (number of genes, domains, etc) We are solving a problem in a workshop I'm teaching now that turns to a non-parametric solution if you can't change genome list properties with other data inputs. That data that changes genome won't change in the optimization process.

Thanks and best.

Views: 10205

Replies to This Discussion

I just want the genes inside to inhert previous values, so that I don´t have to modify them manually since they are a lot of them

Can I suggest the Save>Restore State function from the Solution Menu

How do you get the input values though?

inside to inherit previous values

Save the state with a set of values that you want to use again in the future

Thanks, I see, but I didn´t mean that. I´m working with a VB Script by David Rutten (http://www.grasshopper3d.com/forum/topics/request-parametric-genome...) to control the number of genes with a slider, introduced as a counter input in the VB component. I was just wondering if it possible to control the value of the genes generated within the Genepool with an input because I already have a set of values for that genes, which are the ones I needed to be inhereted by the genes generated. I could modify these values manually since the genes are sliders, but that is a pain because they are a lot of them.

Maybe there is a simpler way... you could add the gene values to the list you want to inherit. Am I clear?
Example here http://www.grasshopper3d.com/forum/topics/galapagos-dividing-2-rail...

Hi, 

of course there is a way to set the values of a GenePool within a script. That's just how Galapagos and Octopus work.

Here are some snippets of C# code:

GH_Document doc = this.OnPingDocument();
if (doc == null)
{
GAlog += "\r\nDocument not found";
return false;
}

// this line can be replaced by another doc.FindObject function giving you back a representation of the GenePool object from you canvas

GalapagosGeneListObject geneList = (GalapagosGeneListObject)doc.FindObject(new Guid(  -- your Gene Pool's Guid--- ), false);

double max = geneList.Maximum;
double min = geneList.Minimum;
for (int k = 0; k < geneList.Count; k++)
{
geneList[k] = (decimal)(new Value);
}

geneLists[j].ExpirePreview(true);

// to update the solution with the new values

geneLists[j].ExpireSolution(false);

maybe this helps

Best

Thanks Robert, this is helping me today.. in 2017! Best, John.

I've had good success through this thread figuring out in VB how to dynamically set the number, range and decimals for my gene pools, but am having a harder time getting to adjusting the values. I can't seem to find a way to access the GalapagosGeneListObject. Any pointers?

Private Sub RunScript(ByVal Genelist As String, ByVal Count As Integer, ByVal MinVal As Double, ByVal MaxVal As Double, ByVal DecimalPlaces As Integer, ByRef A As Object)

For Each obj As IGH_DocumentObject In owner.OnPingDocument().Objects
If (obj.ComponentGuid <> New Guid("{21553c44-ea62-475e-a8bb-62b2a3ee5ca5}")) Then Continue For
If (obj.NickName Like genelist) Then
CallByName(obj, "Count", CallType.Set, count)
CallByName(obj, "Minimum", CallType.Set, MinVal)
CallByName(obj, "Maximum", CallType.Set, MaxVal)
CallByName(obj, "Decimals", CallType.Set, DecimalPlaces)
Return
End If
Next

End Sub

Never mind...sorted it out:

Dim SetIdx as Int32 = i 'value index to set

Dim SetValue as Double = v 'value to set

CallByName(obj, "Value", CallType.Set, SetIdx, SetValue)

In case anyone comes here looking for a ready-made functional code component that allows you to dynamically adjust the number of sliders, decimal places, and range of a gene pool...also to one-click randomize the values.

Attachments:

Now you have to post it in the Milkbox ;)

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service