Hi Abraham,
I agree with Arne. If you want, you may run the following piece of code in MATLAB to verify that your simultaneous equations have several solutions. Attached is also one file where you can easily see there are multiple points where the two surface plots of the equations cross each other (where the solutions exist).
%=============================
%Graphical Visualization
%The solutions of the two equations z1 and z2 is basically at the
%intersection points (i.e. when z1 = z2)
%x=0:0.2:20;
%y=-10:0.2:10;
[x,y] = meshgrid([0:.2:20],[-10:0.2:10]);
z1=(4x.sin(y))+0.6;
surfc(x,y,z1)
colormap hsv
%figure
hold on
z2=4sqrt(x)-4x.*cos(y)+0.3;
surfc(x,y,z2)
colormap hsv
%====================================================
Best wishes,
Destin
On Fri, Apr 20, 2012 at 10:46 AM, Arne Stolbjerg Drud wrote:
Abraham:
-
If GAMS declares a solution feasible then it is VERY likely feasible and
if it is not what you expect, then look for a reason. A model with Sin and
Cos can have multiple solutions so you may just have found another solution.
-
If you try to start from a point near your expected solution, for example
x1.l = -0.2; x2.l = 0.9; you will get another solution, but not the one you
want:
LOWER LEVEL UPPER
MARGINAL
---- VAR X1 -INF -0.1669 100.0000 .
---- VAR X2 -INF 0.9031 100.0000 .
---- VAR Z -INF . +INF .
- If you compute the residuals using your own point you will find that it is
not feasible:
scalar res1, res2;
x1.l = -0.186; x2.l = 0.940;
res1 = 4X2.lSin(X1.l) - (-0.6) ;
res2 = 4SQR(X2.l)-4X2.l*COS(X1.l) - (-0.3) ;
display res1, res2 ;
gives:
---- 17 PARAMETER res1 = -0.095
PARAMETER res2 = 0.139
So there is probably an error in your initial model. Good luck.
Arne
Arne Stolbjerg Drud
ARKI Consulting & Development A/S
Bagsvaerdvej 246A, DK-2880 Bagsvaerd, Denmark
Phone: (+45) 44 49 03 23, Fax: (+45) 44 49 03 33, email: adrud@arki.dk
-----Original Message-----
From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On
Behalf Of ABY
Sent: Friday, April 20, 2012 7:31 AM
To: gamsworld
Subject: Solving Simultenous Equations
Hi,
I am new to GAMS and wants to solve two simultenous equations;
4X2Sin(X1) = -0.6
4SQR(X2)-4X2*COS(X1) = -0.3 ;
and so I used following program;
VARIABLES X1, X2,Z;
EQUATIONS EQ1, EQ2,OBJ;
EQ1… 4X2Sin(X1) =e= -0.6 ;
EQ2… 4SQR(X2)-4X2*COS(X1) =e= -0.3 ;
X1.l=0;X2.l=0;X1.up=100;X2.up=100;
OBJ… Z =E= 0;
MODEL LPKKT /OBJ,EQ1,EQ2/;
SOLVE LPKKT USING dnlp minimizing Z;
I am getting output as
LOWER LEVEL UPPER MARGINAL
---- VAR X1 -INF -0.940 100.000 EPS
---- VAR X2 -INF 0.186 100.000 .
---- VAR Z -INF . +INF .
Actual output to get is X1=-0.186&X2=+0.940 ==>Can anybody please help me
in getting correct output
thanx in advance
Abraham
\
Visualization.bmp (2.56 MB)