[R] Optimization

Berwin A Turlach berwin at maths.uwa.edu.au
Tue Jul 17 10:22:19 CEST 2007

G'day Massimiliano,

On Mon, 16 Jul 2007 22:49:32 +0200
"massimiliano.talarico" <massimiliano.talarico at poste.it> wrote:

> Dear all,
> I need a suggest to obtain the max of this function:
> Max x1*0.021986+x2*0.000964+x3*0.02913
> with these conditions:
> x1+x2+x3=1;
> radq((x1*0.114434)^2+(x2*0.043966)^2+(x3*0.100031)^2)=0.04;
> x1>=0;
> x1<=1;
> x2>=0;
> x2<=1;
> x3>=0;
> x3<=1;

Note that given the constraint x1+x2+x3=1 and the positivity constraints on x1,
x2 and x3, the conditions that all of them should be <=1 are redundant.

I would go about as follows:

x1+x2+x3=1 means x1=1-x2-x3

plug this into the next constraint to obtain:

a*(1-x2-x3)^2+b*x2^2+c*x3^2=0.04^2 for suitable a, b, c.

Note that for any value of x3, you can solve this equation for x2.

Hence, take a grid of x3 values between 0 and 1 and calculate the correpsonding
x2 values.  From x3 and x2 calculate x1.  Discard all tuples that do not
fulfill the positivity constraints and calculate the function values for the
remaining ones.  

If the grid of x3 values is fine enough, that should give you an idea what the
solution should be.

Alternatively, you could write a function that takes values of x3 and does all
the computations outline above (return -Inf if the value x3 is not feasible)
and then pass the function to optimise() for numerical optimisation...

Hope this helps.



=========================== Full address =============================
Berwin A Turlach                            Tel.: +65 6515 4416 (secr)        
Dept of Statistics and Applied Probability        +65 6515 6650 (self)
Faculty of Science                          FAX : +65 6872 3919       
National University of Singapore                                      
6 Science Drive 2, Blk S16, Level 7          e-mail: statba at nus.edu.sg
Singapore 117546                    http://www.stat.nus.edu.sg/~statba

More information about the R-help mailing list