Re: Constrained Optimization Algorithm



On 22 Sie, 21:28, cyc1...@xxxxxxxxx wrote:
Hi all,

I am facing the following Optimization problem. I'll post an example
with a simple case.

I have 2 variables, x and y.

I want to maximize (f(x) + g(y))/2 while keeping x + y <= 10.

I know this is a NLP problem.
I have tried to use the Newton-Raphson algorithm but I dont' like it
because it highly depends on the initial chosen point.

I'll eventually have to expand this problem to thousands of variables
(as opposed to having only 2 variables: x and y).

Anyone know which I NLP algorithm I should use and where I can find
resources about that particular algorithm?

Thanks

you can use one of the standard algorithms described in chapter 10 of
the book: 'Numerical Recipies in C' by Press, Teukolsky available at:
http://www.nrbook.com/a/bookcpdf.php
but i would like to encourage you to try to use genetic algorithm.
I made simple case when you try to find the curve of minimal length
between two points, that is find the variables x_1,...x_n such that
x_1^2+...+x_n^2 is minimal. The code for 20 variables which find the
solution quite fast, in free pascal compiler is:


program mutation;
uses crt,graph;
var x:array[1..20] of integer;
gd,gm,i:integer;
n:int64;
s1,s2:double;
st:string;

begin
randomize;
DetectGraph(gd,gm);
InitGraph(gd,gm,' ');
x[1]:=1; x[20]:=20;

for i:=2 to 19 do
x[i]:=-5+random(40); //individual x_i with random 'genes'

repeat
ClearDevice;
for i:=1 to 20 do
putpixel(10*i+50,10*x[i]+50,red);
Str(n:8,st); Outtextxy(250,150,st);
delay(100);

i:=2+random(18); //mutation +
s1:=(x[i]-x[i-1])*(x[i]-x[i-1])+(x[i+1]-x[i])*(x[i+1]-x[i]);
//you need to evaluate the lenght of the curve only in the mutation
point!
s2:=(x[i]+1-x[i-1])*(x[i]+1-x[i-1])+(x[i+1]-x[i]-1)*(x[i+1]-x[i]-1);
if s2<=s1 then
x[i]:=x[i]+1;

i:=2+random(18); //mutation -
s1:=(x[i]-x[i-1])*(x[i]-x[i-1])+(x[i+1]-x[i])*(x[i+1]-x[i]);
s2:=(x[i]-1-x[i-1])*(x[i]-1-x[i-1])+(x[i+1]-x[i]+1)*(x[i+1]-x[i]+1);
if s2<=s1 then
x[i]:=x[i]-1;
n:=n+1;
until keypressed;

CloseGraph;
end.

Regards,
Martin, Poland
.



Relevant Pages

  • Re: Confusion about splitting classes to allow sharing of resources
    ... allows the selection of the algorithm to be separated from the routine computations. ... Spline classes, such as LinearSpline and CubicSpline, based on the same ... The higher-level class Curve should be able to select ... actual interpolation to the algorithm de jour one set of points at a time. ...
    (comp.object)
  • Re: pattern match
    ... reliability) algorithm for pattern matching. ... Could it be a good solution to use the euclidean distance ... the shape is in reality a curve, i'm working on a 2D world. ... and give as result the angle applied. ...
    (sci.image.processing)
  • Re: Splitting a bezier curve
    ... It consists of two distinct ... From the point on or near the curve, find the parameter t in the ... Split the curve at t using the algorithm as seen in the other reply. ... I sell the code (Delphi), if you are interested, let me know. ...
    (comp.graphics.algorithms)
  • Re: How to pick best encryption algorithm based on application
    ... the optimum encryption algorithms for your particular application. ... algorithm for a given environment, but choosing an optimal algorithm is an extremely complex process that can take weeks all on it's own. ... Building a curve system like that would actually be fairly meaningless. ...
    (sci.crypt)
  • Re: pattern match
    ... If a plot them i get a curve starting from the vertical and ending to the horizontal. ... In most cases, matching shapes is done by considering appropriate "feature" points, even if the input were images or other geometric shapes. ... My algorithm should be able to apply a rototraslation to the second shapeto match it at best into the first shape. ... and it is the case that the following is the most important detail: do you have a pairing for the corresponding points for the curves? ...
    (comp.graphics.algorithms)