Objective function is wrongly calculated

Hi,

i’m trying to solve an miqcp problem with binary and real variables. And the value of the objective function given by the solver
is really différent from my hand made calculation.

to be much clear here is my problem description:

variable: Positive variable x(var)
binary variable u(var)

objectiv: “obj… z =E=sum((var), (x(var)*u(var)*mat_kp(var)));”

mat_kp=
5E-11 5E-11 1.25E-10 1.25E-10 1.5E-10 1.5E-10 2.5E-11 2.5E-11 1.25E-10 1.25E-10 1.5E-10 1.5E-10 2.5E-11 2.5E-11 1.25E-10 1.25E-10 7.5E-11 7.5E-11 2.5E-11 2.5E-11 0 0 0 0 0 0 0 0 0 0 0 0 3E-10 3E-10 1.75E-10 1.75E-10 2.25E-10 2.25E-10 5.5E-10 5.5E-10 2E-10 2E-10 2.75E-10 2.75E-10 1.5E-10 1.5E-10 7.5E-11 7.5E-11 2.25E-10 2.25E-10 7.5E-11 7.5E-11 7.5E-11 7.5E-11 1.75E-10 1.75E-10 2.5E-11 2.5E-11 2.5E-10 2.5E-10 3E-10 3E-10 3.25E-10 3.25E-10 4.75E-10 4.75E-10 4.75E-10 4.75E-10 2.75E-10 2.75E-10 0 0 5.5E-10 5.5E-10 8E-10 8E-10 6E-10 6E-10 1.5E-10 1.5E-10 5E-11 5E-11 0 0 0 0 0 0

So my problem is that when i check the given solution (set of X and U) by calculating it manually XUmat_kp i don’t have the same result,
i firstly thought about approximation, but the difference is to big.

So i wanted to know why this supposedly optimal objective value is different from the hand made calculation with the same set of variables.

Regards


\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hi Ali

Well, this sounds like my wife complaining about the computer, not doing what she wants it to do…

Gams does not make mistakes, it just does, what you want it to do (of course, there might be a bug once in a while).

If “manually calculated”:

Myobj = SUM(var, X.L(var) * U.L(var) * mat_kp(var))

is not equal to OBJ.L, this would probably be a bug, but I have the feeling that your manual calculation is wrong,

It is hard to know, as your do not give enough information.

Cheers

Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Abd Ali
Sent: Freitag, 5. September 2014 11:59
To: gamsworld@googlegroups.com
Subject: Objective function is wrongly calculated



Hi,

i’m trying to solve an miqcp problem with binary and real variables. And the value of the objective function given by the solver
is really différent from my hand made calculation.

to be much clear here is my problem description:

variable: Positive variable x(var)
binary variable u(var)

objectiv: “obj… z =E=sum((var), (x(var)*u(var)*mat_kp(var)));”

mat_kp=

5E-11


5E-11


1.25E-10


1.25E-10


1.5E-10


1.5E-10


2.5E-11


2.5E-11


1.25E-10


1.25E-10


1.5E-10


1.5E-10


2.5E-11


2.5E-11


1.25E-10


1.25E-10


7.5E-11


7.5E-11


2.5E-11


2.5E-11


0


0


0


0


0


0


0


0


0


0


0


0


3E-10


3E-10


1.75E-10


1.75E-10


2.25E-10


2.25E-10


5.5E-10


5.5E-10


2E-10


2E-10


2.75E-10


2.75E-10


1.5E-10


1.5E-10


7.5E-11


7.5E-11


2.25E-10


2.25E-10


7.5E-11


7.5E-11


7.5E-11


7.5E-11


1.75E-10


1.75E-10


2.5E-11


2.5E-11


2.5E-10


2.5E-10


3E-10


3E-10


3.25E-103.25E-10 4.75E-10 4.75E-10 4.75E-10 4.75E-10 2.75E-10 2.75E-10 0 0 5.5E-10 5.5E-10 8E-10 8E-10 6E-10 6E-10 1.5E-10 1.5E-10 5E-11 5E-11 0 0 0 0 0 0


So my problem is that when i check the given solution (set of X and U) by calculating it manually XUmat_kp i don’t have the same result,
i firstly thought about approximation, but the difference is to big.

So i wanted to know why this supposedly optimal objective value is different from the hand made calculation with the same set of variables.

Regards

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Another thought: mat_kp is very, very small and that might be a problem. The precision of solving a model is usually 1e-7.

Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Abd Ali
Sent: Freitag, 5. September 2014 11:59
To: gamsworld@googlegroups.com
Subject: Objective function is wrongly calculated



Hi,

i’m trying to solve an miqcp problem with binary and real variables. And the value of the objective function given by the solver
is really différent from my hand made calculation.

to be much clear here is my problem description:

variable: Positive variable x(var)
binary variable u(var)

objectiv: “obj… z =E=sum((var), (x(var)*u(var)*mat_kp(var)));”

mat_kp=

5E-11


5E-11


1.25E-10


1.25E-10


1.5E-10


1.5E-10


2.5E-11


2.5E-11


1.25E-10


1.25E-10


1.5E-10


1.5E-10


2.5E-11


2.5E-11


1.25E-10


1.25E-10


7.5E-11


7.5E-11


2.5E-11


2.5E-11


0


0


0


0


0


0


0


0


0


0


0


0


3E-10


3E-10


1.75E-10


1.75E-10


2.25E-10


2.25E-10


5.5E-10


5.5E-10


2E-10


2E-10


2.75E-10


2.75E-10


1.5E-10


1.5E-10


7.5E-11


7.5E-11


2.25E-10


2.25E-10


7.5E-11


7.5E-11


7.5E-11


7.5E-11


1.75E-10


1.75E-10


2.5E-11


2.5E-11


2.5E-10


2.5E-10


3E-10


3E-10


3.25E-103.25E-10 4.75E-10 4.75E-10 4.75E-10 4.75E-10 2.75E-10 2.75E-10 0 0 5.5E-10 5.5E-10 8E-10 8E-10 6E-10 6E-10 1.5E-10 1.5E-10 5E-11 5E-11 0 0 0 0 0 0


So my problem is that when i check the given solution (set of X and U) by calculating it manually XUmat_kp i don’t have the same result,
i firstly thought about approximation, but the difference is to big.

So i wanted to know why this supposedly optimal objective value is different from the hand made calculation with the same set of variables.

Regards

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Thank you very much for answering so quickely,

I agree that gams can’t make mistakes but the calculation is so simple that i can’t find where i could make a mistake.
I take the vector of X and U given by gams and i take the mat_kp that i gave to the model for the optimization after that this is just a product and a sum so…

About the precision i already thought about that and tried to normalize around 1 or to multiply it by a big number but the same is happening.

Sorry if my questions sounded stupid but i was thinking that maybe i missed something about the optimization theory.

Thank you very much



Le vendredi 5 septembre 2014 13:03:52 UTC+2, Renger van Nieuwkoop a écrit :

Another thought: mat_kp is very, very small and that might be a problem. The precision of solving a model is usually 1e-7.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Abd Ali
Sent: Freitag, 5. September 2014 11:59
To: gams...@googlegroups.com
Subject: Objective function is wrongly calculated



Hi,

i’m trying to solve an miqcp problem with binary and real variables. And the value of the objective function given by the solver
is really différent from my hand made calculation.

to be much clear here is my problem description:

variable: Positive variable x(var)
binary variable u(var)

objectiv: “obj… z =E=sum((var), (x(var)*u(var)*mat_kp(var)));”

mat_kp=

5E-11


5E-11


1.25E-10


1.25E-10


1.5E-10


1.5E-10


2.5E-11


2.5E-11


1.25E-10


1.25E-10


1.5E-10


1.5E-10


2.5E-11


2.5E-11


1.25E-10


1.25E-10


7.5E-11


7.5E-11


2.5E-11


2.5E-11


0


0


0


0


0


0


0


0


0


0


0


0


3E-10


3E-10


1.75E-10


1.75E-10


2.25E-10


2.25E-10


5.5E-10


5.5E-10


2E-10


2E-10


2.75E-10


2.75E-10


1.5E-10


1.5E-10


7.5E-11


7.5E-11


2.25E-10


2.25E-10


7.5E-11


7.5E-11


7.5E-11


7.5E-11


1.75E-10


1.75E-10


2.5E-11


2.5E-11


2.5E-10


2.5E-10


3E-10


3E-10


3.25E-103.25E-10 4.75E-10 4.75E-10 4.75E-10 4.75E-10 2.75E-10 2.75E-10 0 0 5.5E-10 5.5E-10 8E-10 8E-10 6E-10 6E-10 1.5E-10 1.5E-10 5E-11 5E-11 0 0 0 0 0 0


So my problem is that when i check the given solution (set of X and U) by calculating it manually XUmat_kp i don’t have the same result,
i firstly thought about approximation, but the difference is to big.

So i wanted to know why this supposedly optimal objective value is different from the hand made calculation with the same set of variables.

Regards

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

I’m so sorry i found why my calculation was wrong, the value displayed trough GAMS ide isn’t the exact one,
i get the good results if i get it trough a java app with “…getVariable(“x”)” “…getVariable(“u”)”.

Thank you for your help, an other eye on the question is always good, even more when you search a solution during a long time ^^.

regards
Ali


Le vendredi 5 septembre 2014 14:55:13 UTC+2, Abd Ali a écrit :

Thank you very much for answering so quickely,

I agree that gams can’t make mistakes but the calculation is so simple that i can’t find where i could make a mistake.
I take the vector of X and U given by gams and i take the mat_kp that i gave to the model for the optimization after that this is just a product and a sum so…

About the precision i already thought about that and tried to normalize around 1 or to multiply it by a big number but the same is happening.

Sorry if my questions sounded stupid but i was thinking that maybe i missed something about the optimization theory.

Thank you very much



Le vendredi 5 septembre 2014 13:03:52 UTC+2, Renger van Nieuwkoop a écrit :

Another thought: mat_kp is very, very small and that might be a problem. The precision of solving a model is usually 1e-7.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Abd Ali
Sent: Freitag, 5. September 2014 11:59
To: gams...@googlegroups.com
Subject: Objective function is wrongly calculated



Hi,

i’m trying to solve an miqcp problem with binary and real variables. And the value of the objective function given by the solver
is really différent from my hand made calculation.

to be much clear here is my problem description:

variable: Positive variable x(var)
binary variable u(var)

objectiv: “obj… z =E=sum((var), (x(var)*u(var)*mat_kp(var)));”

mat_kp=

5E-11


5E-11


1.25E-10


1.25E-10


1.5E-10


1.5E-10


2.5E-11


2.5E-11


1.25E-10


1.25E-10


1.5E-10


1.5E-10


2.5E-11


2.5E-11


1.25E-10


1.25E-10


7.5E-11


7.5E-11


2.5E-11


2.5E-11


0


0


0


0


0


0


0


0


0


0


0


0


3E-10


3E-10


1.75E-10


1.75E-10


2.25E-10


2.25E-10


5.5E-10


5.5E-10


2E-10


2E-10


2.75E-10


2.75E-10


1.5E-10


1.5E-10


7.5E-11


7.5E-11


2.25E-10


2.25E-10


7.5E-11


7.5E-11


7.5E-11


7.5E-11


1.75E-10


1.75E-10


2.5E-11


2.5E-11


2.5E-10


2.5E-10


3E-10


3E-10


3.25E-103.25E-10 4.75E-10 4.75E-10 4.75E-10 4.75E-10 2.75E-10 2.75E-10 0 0 5.5E-10 5.5E-10 8E-10 8E-10 6E-10 6E-10 1.5E-10 1.5E-10 5E-11 5E-11 0 0 0 0 0 0


So my problem is that when i check the given solution (set of X and U) by calculating it manually XUmat_kp i don’t have the same result,
i firstly thought about approximation, but the difference is to big.

So i wanted to know why this supposedly optimal objective value is different from the hand made calculation with the same set of variables.

Regards

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.