constrained optimalisation with f(x,y) polynomals

ivran hosti at telenet.be
Tue Aug 7 15:49:49 CEST 2012


Michaël ,


I really appreciate your reply!! It helped me a lot.


Tkx!
Iwein

----- Oorspronkelijk e-mail -----

Van: "michael.baudin [via Scilab / Xcos - Mailing Lists Archives]" <ml-node+s994242n4024676h27 at n3.nabble.com>
Aan: "ivran" <hosti at telenet.be>
Verzonden: Dinsdag 7 augustus 2012 10:18:53
Onderwerp: Re: constrained optimalisation with f(x,y) polynomals

Hi,

There is no multivariate polynomial in Scilab, so you cannot
create a 2-variable polynomial by adding to single-variable
polynomials.

With neldermead, it is relatively simple to find the minimum
of a 2-variable function, with nonlinear constraints.
The script below prints the following output (in Scilab 5.3.3):

xopt

10.239741
99.999999

fopt

- 870129.52

copt

1023.974

This is not very accurate, but might be sufficient, depending
on your goals.
If you need a more accurate computation, you may use the fmincon
toolbox :

http://atoms.scilab.org/toolboxes/fmincon

or ipopt:

http://atoms.scilab.org/toolboxes/sci_ipopt

But this might be more complicated, because these two tools
are still in alpha stage.

Best regards,

Michaël

PS

// Optimize an additive 2D polynomial with neldermead.
function [f, c, index]=my2dpolynomial(x, index)
f = []
c = []
if ( index==2 | index==6 ) then
p1 = 1. - 2*x(1) + 3*x(1)^2 + 0.4*x(1)^3
p2 = 5. - 6*x(2) + 7*x(2)^2 + 0.8*x(2)^3
f = -p1 - p2
end
if ( index==5 | index==6 ) then
c1 = x(1) * x(2)
c2 = 1024 - c1
c = [c1 c2]
end
endfunction

rand("seed" , 0);
x0 = [1. 1.].';
// Compute f(x0)
fx0 = my2dpolynomial ( x0 , 2 )
// Compute the constraints:
[ fx0 , cx0, index ] = my2dpolynomial ( x0 , 6 )
// Setup optimization
nm = neldermead_new ();
nm = neldermead_configure(nm,"-numberofvariables",2);
nm = neldermead_configure(nm,"-function",my2dpolynomial);
nm = neldermead_configure(nm,"-x0",x0);
nm = neldermead_configure(nm,"-method","box");
nm = neldermead_configure(nm,"-nbineqconst",2);
nm = neldermead_configure(nm,"-simplex0method","randbounds");
nm = neldermead_configure(nm,"-boundsmin",[0.0 0.0]);
nm = neldermead_configure(nm,"-boundsmax",[100.0 100.0]);
// Check that the cost function is correctly connected.
[ nm , result ] = neldermead_function ( nm , x0 );
//
// Perform optimization
nm = neldermead_search(nm);
xopt = neldermead_get(nm,"-xopt");
disp("xopt")
disp(xopt)
fopt = neldermead_get(nm,"-fopt")
disp("fopt")
disp(fopt)
nm = neldermead_destroy(nm);
disp("copt")
disp(xopt(1)*xopt(2))


On Mon, 6 Aug 2012 13:43:51 -0700 (PDT), ivran < [hidden email] >
wrote:

> hi guys,
>
> I'm having a big problem using scilab and some basic math. I would
> really
> appreciate some help with it 'cause i'm stuck - Consider the
> following
> problem:
>
> 2 polynomials, each describing a coordinate on its own. Together they
> form a
> 2D - f(x1,x2) surface which can have 2 - or more - maximums on a
> certain
> spot.
>
> f(x1) = p1 = 2 3
>
> 4 5 6
> 55.044419 - 1.3570362x1 + 0.0162766x1 - 0.0001039x1 + 0.0000004x1
> -
> 4.592D-10x1 + 1.854D-13x1
>
> f(x2) = p2 = 2 3 4
> 5 6
> 560.98702 - 23.76471x2 + 0.2962816x2 - 0.0009662x2 + 0.0000013x2
> -
> 8.576D-10x2 + 2.074D-13x2
>
> I have two problems here:
>
> 1) Does anyone know how to combine these 1D polynomials to a 2D
> polynomial?
> f(x1, x2) = px1x2 = p1 + p2
> ...won't work. How can I solve this without overloading the '+'
> method?
>
> 2) suppose I *could* combine these 2 functions:
> f(x1, x2) = ...x1 + ...x2 + ...x1^n + ..x2^n
> how can I find the maximum values of this function?, given the
> following
> constraints:
> x1.x2 <= 1024
> x1.x2 >= 0
>
> I'm (a little) familiar with Lagrange and the scilab procedures
> regarding
> this topic... but it would be very helpful if someone could post me a
> example of this (or something close related) 2D constrained
> optimization
> problem.
>
> I'm really stuck at this... could you point me in the right
> direction? ..tkx
> in advance!!
>
> Iwein
>
>
>
>
>
>
> --
> View this message in context:
>
> http://mailinglists.scilab.org/constrained-optimalisation-with-f-x-y-polynomals-tp4024673.html
> Sent from the Scilab users - Mailing Lists Archives mailing list
> archive at Nabble.com.
>
> --
> To unsubscribe from this mailing-list, please send an empty mail to
> [hidden email]
> To check the archives of this mailing list, see
> http://mailinglists.scilab.org/
--
To unsubscribe from this mailing-list, please send an empty mail to
[hidden email]
To check the archives of this mailing list, see
http://mailinglists.scilab.org/






If you reply to this email, your message will be added to the discussion below: http://mailinglists.scilab.org/constrained-optimalisation-with-f-x-y-polynomals-tp4024673p4024676.html
To unsubscribe from constrained optimalisation with f(x,y) polynomals, click here .
NAML




--
View this message in context: http://mailinglists.scilab.org/constrained-optimalisation-with-f-x-y-polynomals-tp4024673p4024684.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20120807/51a7cfec/attachment.htm>


More information about the users mailing list