Grasshopper

algorithmic modeling for Rhino

Hi David, 

 

is there is any tutorials or samples show how to control multiple fitness values

i  mean if we have one to maximize , another to minimize and third to have absolute value

 

i  read your blog which explain the idea in details but still cant perform it as there are no rules to do it ? 

Views: 11296

Replies to This Discussion

There are no rules. You just need to come up with a function that combines your three values. It might look something like this:

 

f = -A + B - Abs(C - 15)

 

where A is the value that needs to be minimized, B is the value that needs to be maximized and C is the value that aims for the constant absolute value. You may need to add weighting factors to this to avoid one variable being much stronger than the others.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

The weighting factors you spoke about are the tricky part to me. Is there any resource (book, PDF, etc.) that could help you to find the better values?

 

I've maked using intuition, but I guees that must be somewhere some rules to make this process more..."scientist", "accurate".

 

Best Regards.

No books or resources I'm aware of. But the theory is very simple. What you should aim to do is 'normalise' all your fitness components. I.e. make sure that the worst possible fitness and the best possible fitness for each component have the same value.

 

Let's say you have your three components as mentioned before, A, B and C. A is to be minimized, B is to be maximized and C is to be optimised at 15. Furthermore, the possible values of A can vary somewhere between 10 and 500, B can vary between 0.1 and 0.8 and C can be anywhere roughly in between 5 and 60.

 

So the best possible fitness will be {A=10, B=0.8, C=15} and the worst possible fitness will be {A=500, B=0.1, C=60}.

 

In table form:

A {min = 10; max = 500; range = 490; target = 10}

B {min = 0.1; max = 0.8; range = 0.7; target = 0.8}

C {min = 5; max = 60; range = 55; target = 15}

 

The range value is the important here because it tells you the 'strength' of the variable in the total fitness. Typically you aim to make all variables roughly equally strong. Which means our fitness function needs to have weighting factors, so that the components of the fitness function are all {0.0, 1.0}. The old function (without weighting) looked like this:

 

f = -A + B - Abs(C - 15)

 

The new function might look like this:

 

f = -((A-10) / 490) + ((B-0.1) / 0.7) - Abs((C-15) / 55)

 

The 'rules' could be summarised roughly as follows I suppose:

 

  • The sign in front of each variable indicates whether we want to maximize (+), minimize (-) or optimize (-) the variable.
  • If a variable is to be optimized, then the fitness is defined as Abs(x - c), where x is the variable, and c is the target value. (I.e. optimization equals minimization of the difference between the variable and the target, hence the minus-symbol).
  • Variables need to be 'centered' at zero (or any other constant numeric, but zero is easiest), so subtract the lowest possible value it can have from the variable.
  • Variables need to be normalised to the (0~1) domain (or any other constant domain, but 0~1 is easiest), so divide the centered variable by the domain range.

 

Assuming the fitness progression is linear (which is not a given at all), the fitness ranges before normalisation looked like this:

and the normalisation weighting factors pull them towards each other.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Btw. the minimum and maximum values a fitness component can have cannot be inferred from the problem. One way to figure them out, is simply try a boat-load of different combinations (and I mean a boat-load, way more than you'd need for your typical solver run) and record the ranges.

 

But hopefully you have a reasonably advanced understanding of the problem you're solving so you can probably guesstimate reasonable min/max values.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Really nice post. All concepts clear. More complicated patterns could be achieved mixing that concepts you explain really well here; the problem could be that you said: don't know the correct range...and like anyone could see initial values are really important using galapagos.

 

Thanks for this really nice and detailed explanation :)

Hi David,

I have seen your comment and followed you in my simulation.

My fitness is to max. the daylight factor, min. the daylight glare probability and min. the energy consumption. 

However, the expression seems not working in my case. Could you please let me know what I can do in this case?

Thank you!

-Yanting

One of your values is not a number, it is Null. I don't know where it comes from, but it may either be a bug somewhere upstream or -if nulls are expected- you have to deal with them.

Hi, David, Thanks for your replying. 

Yes, you were right! I found out the reason. It is because of the Null. 

BTW, is there any rule that I should follow to deal with the weight of each fitness? As the whole restriction function set now, I cannot get any process displayed on the window for 5 hours. 

Do you have any suggestions?

-Yanting

How long does it take to perform one iteration? If it's a long time then Galapagos is probably not a good solution since it will require several hundred iterations before it will generate anything close to a good answer.

Daylight factor, DGP, and energy consumption might take 2 min/iteration. 

Is there any way can find an optimal solution with a plugin, such as Galapagos? 

Hi David 

 

by the way, where i have to paste these Functions

 

is it within Fitness Target or Fitness

 

if the variables are the sliders, is that mean i have to rename sliders as A, B, C .. etc 

 

i will really hope if you can show us a simple sample, David

 

 

 

 

You need to put this function into Grasshopper. The result of this function becomes the fitness that Galapagos looks at. You can either use a Function component, or a VB/C#/Python component, or create the function using a bunch of Math components hooked together.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service