Hi,
I have two vectors of decision variables that i want to use in my objective function to calculate the Euclidean distance between them:
I write this: sqrt(sum(j, power(v1(j) - v2(j)),2))
And i get an error because the domain changes. I understood that when i am using the power function inside the sum it’s calculating a new value that is not over the domain j.
So is there a way to do this in GAMS in the same step, or over multiple steps?
Thanks,
Sara
–
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 Sara
You could just add an equation:
Eq_power…
SUMPOW =E= sum(j, power(V1(j) - V2(j)),2);
Eq_obj…
OBJ =E= sqrt(SUMPOW);
Cheers
Renger
From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Sara Amr
Sent: Montag, 7. Dezember 2015 22:46
To: gamsworld
Subject: using power inside of sum
Hi,
I have two vectors of decision variables that i want to use in my objective function to calculate the Euclidean distance between them:
I write this: sqrt(sum(j, power(v1(j) - v2(j)),2))
And i get an error because the domain changes. I understood that when i am using the power function inside the sum it’s calculating a new value that is not over the domain j.
So is there a way to do this in GAMS in the same step, or over multiple steps?
Thanks,
Sara
–
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.