Reputation: 51
I have problem on building the constraints matrices of genetic algorithms in Matlab. I want to import these matrices in GA function for a problem that has the following constraints:
a1<a2<a3...an-1<an , 0<ai<90, n=number of variables.
Matlab's documentation didn't help me because it refers only to simple equations and not to this kind of constraints.
I'm new to GA and every help would be acceptable!
Upvotes: 5
Views: 2065
Reputation: 11
Maybe you can provide following options for defining inequality constraints for a 5 parameter problem.
Aineq = [1 -1 0 0 0; 0 1 -1 0 0; 0 0 1 -1 0; 0 0 0 1 -1; ]
and
b = [0 0 0 0]
This will translate into the following constraints:
a1<a2
a2<a3
a3<a4
a4<a5
which is equivalent to a1<a2<a3<a4<a5
Upvotes: 1
Reputation: 1220
Default constraint provided by matlab will not suit for Your needs.
You may try to translate Your constrains and add a penalty condition, like this:
goalfunction value = Inf if conditions are not fulfilled
But this will fail to find the optimum, so what is my solution
You may also try to translate the problem, and instead of finding Your values, just find this:
b(1), b(2), ... b(n), where bi = a(i)-a(i-1) and b(i) > 0 for each i
So you will only find distances between each of your initial variables, and provided that they are positive you will find monotically icreasing sequence, and that's what You need. Tell me if it satisfies You.
PS. Constrains in optimiaztion are great thing to solve, and it's not always straightforward how we will translate each real-world constrain into aX > b
:)
Upvotes: 1