## How could you modify this semi-infinite optimization to global optimization using GlobalSearch?

Asked by Richárd Tóth

### Richárd Tóth (view profile)

on 26 Jul 2019
Latest activity Edited by Matt J

### Matt J (view profile)

on 26 Jul 2019
Accepted Answer by Matt J

### Matt J (view profile)

Hello
I managed to create a script and find local minimum for my problem based on this example:
But how could you modify that example into a form that uses GlobalSearch to find global minimum? Let's say you have the myfun.m and mycon.m files. Normally you just set x0 and call fseminf and you have a local minimum. I suppose you need to do something like what is written in the answer here:
So let's say you do this : w1=1:100 and w2=1:100. What next? If you could show me how to modify this MathWorks example, then I could modify my scripts.
Thanks

Richárd Tóth

### Richárd Tóth (view profile)

on 26 Jul 2019
or is it easier if I simply call fseminf lots of times with different values? Is my code going to be as efficient and fast as by using GA,GlobalSearch or some other solver?

Answer by Matt J

on 26 Jul 2019
Edited by Matt J

### Matt J (view profile)

on 26 Jul 2019

If you could show me how to modify this MathWorks example, then I could modify my scripts.
It would look like below,
myfun=@(x) norm(x-0.5).^2;
[w1,w2]=deal(1:100);
x0=ga(myfun,3,A,b,Aeq,beq,lb,ub,@(x) nonlcon(x,w1,w2));
function [c,ceq]=nonlcon(X,w1,w2)
K1 = sin(w1*X(1)).*cos(w1*X(2)) - 1/1000*(w1-50).^2 -...
sin(w1*X(3))-X(3)-1;
K2 = sin(w2*X(2)).*cos(w2*X(1)) - 1/1000*(w2-50).^2 -...
sin(w2*X(3))-X(3)-1;
c=[K1;K2];
ceq=[];
end
Then, you feed the x0, returned from ga(), as the initial guess to fseminf, exactly as implemented at