still bogged with minlp

Archive of Gamsworld Google Group
Post Reply
Archiver
User
User
Posts: 7876
Joined: 7 years ago

still bogged with minlp

Post by Archiver »



Hi,
I am still working on the problem that I asked about few weeks ago.
My best guess after reading the book is that I should use an indicator
instead of conditional expressions when I sum up my cost. But still I
got an "Endogenous $ operation not allowed."

Here is my code:

set face_number /1*8/;
set new_face_vector_length face vectors multiplied by M /1*3/;
set old_face_vector_length face vectors that already multiplied
eigenface /1*5/;

parameter face_vectors(face_number, old_face_vector_length) /
$ondelim
$include face_vectors.txt
$offdelim
/;

variable M(new_face_vector_length, old_face_vector_length);
variable projected_face_vectors(face_number, new_face_vector_length);

equations projection(face_number, new_face_vector_length);
projection(face_number, new_face_vector_length) ..
projected_face_vectors(face_number, new_face_vector_length)
=e= sum(old_face_vector_length, M(new_face_vector_length,
old_face_vector_length) * face_vectors(face_number,
old_face_vector_length));

integer variable indicator(face_number, face_number, face_number);
variable cost;

alias (face_number, f1, f2, f3, f4, f5, f6);
alias (new_face_vector_length, n1, n2, n3, n4);
alias (old_face_vector_length, o1, o2);

equations cost_function, filter_function(f4, f5, f6);
cost_function ..
cost =e= sum((f1, f2, f3),
indicator(f1, f2, f3)*
(sum(n1, power(projected_face_vectors(f1, n1) -
projected_face_vectors(f3, n1), 2)) -
sum(n2, power(projected_face_vectors(f1, n2) -
projected_face_vectors(f2, n2), 2))));

filter_function(f4, f5, f6) ..
indicator(f4, f5, f6) =e= 1 $(sum(o1, power(face_vectors(f4, o1) -
face_vectors(f5, o1), 2)) >
sum(o2, power(face_vectors(f4, o2) -
face_vectors(f6, o2), 2)) and
sum(n3, power(projected_face_vectors(f4,
n3) - projected_face_vectors(f5, n3), 2)) <
sum(n4,power(projected_face_vectors(f4,
n4) - projected_face_vectors(f6, n4), 2)));

Model new_projection_space /all/ ;
Solve new_projection_space using minlp minimizing cost ;

display M.l, M.m;

Many thanks.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to gamsworld@googlegroups.com
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en
-~----------~----~----~----~------~----~------~--~---


Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: still bogged with minlp

Post by Archiver »



Eunice,

GAMS does not reformulate logical expressions. You need to do this by
hand. So forget the $ operator for your pourpose. If you have read the
book I recommended, it explained how to use the bigM method to
linearize logical constraintts. For example, if you have a logical
expression i=1 a>b then you can reformulate this as

a b - bigM*(1-i)

Try to evaluate: If i=1 then the first constraint will not be
effictive if bigM is big enough while the second equation will read
a>b. If i=0, the first constraint ensures a b + 1e-6 - bigM*(1-
i) or some other small number. bigM can be usually computer from the
data of the problem, don't make it just "big", since the solvers won't
like this.

This way you can define two indicators

i=1 a>b
j=1 c>d

Now you can have a third indicator that has to be defined as

k=1 i=1 and j=1

using similar constraints. You find these explicitely in the book.

Currently you multiply your indicator k with the values you want to
minimze. This results in very bad non-convexities. You can also
rewrite things in the a better what that will allow the solver to do a
better job. Before I go into details I let you do the proper indicator
reformulation and then resent the model. Next time you might want to
include your file face_vectors.txt so one can try to run the model.

Hope this helps.
Michael

On Sep 13, 10:36 am, lweunice wrote:
> > Hi,
> > I am still working on the problem that I asked about few weeks ago.
> > My best guess after reading the book is that I should use an indicator
> > instead of conditional expressions when I sum up my cost. But still I
> > got an "Endogenous $ operation not allowed."
> >
> > Here is my code:
> >
> > set face_number /1*8/;
> > set new_face_vector_length face vectors multiplied by M /1*3/;
> > set old_face_vector_length face vectors that already multiplied
> > eigenface /1*5/;
> >
> > parameter face_vectors(face_number, old_face_vector_length) /
> > $ondelim
> > $include face_vectors.txt
> > $offdelim
> > /;
> >
> > variable M(new_face_vector_length, old_face_vector_length);
> > variable projected_face_vectors(face_number, new_face_vector_length);
> >
> > equations projection(face_number, new_face_vector_length);
> > projection(face_number, new_face_vector_length) ..
> > projected_face_vectors(face_number, new_face_vector_length)
> > =e= sum(old_face_vector_length, M(new_face_vector_length,
> > old_face_vector_length) * face_vectors(face_number,
> > old_face_vector_length));
> >
> > integer variable indicator(face_number, face_number, face_number);
> > variable cost;
> >
> > alias (face_number, f1, f2, f3, f4, f5, f6);
> > alias (new_face_vector_length, n1, n2, n3, n4);
> > alias (old_face_vector_length, o1, o2);
> >
> > equations cost_function, filter_function(f4, f5, f6);
> > cost_function ..
> > cost =e= sum((f1, f2, f3),
> > indicator(f1, f2, f3)*
> > (sum(n1, power(projected_face_vectors(f1, n1) -
> > projected_face_vectors(f3, n1), 2)) -
> > sum(n2, power(projected_face_vectors(f1, n2) -
> > projected_face_vectors(f2, n2), 2))));
> >
> > filter_function(f4, f5, f6) ..
> > indicator(f4, f5, f6) =e= 1 $(sum(o1, power(face_vectors(f4, o1) -
> > face_vectors(f5, o1), 2)) >
> > sum(o2, power(face_vectors(f4, o2) -
> > face_vectors(f6, o2), 2)) and
> > sum(n3, power(projected_face_vectors(f4,
> > n3) - projected_face_vectors(f5, n3), 2)) > sum(n4,power(projected_face_vectors(f4,
> > n4) - projected_face_vectors(f6, n4), 2)));
> >
> > Model new_projection_space /all/ ;
> > Solve new_projection_space using minlp minimizing cost ;
> >
> > display M.l, M.m;
> >
> > Many thanks.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to gamsworld@googlegroups.com
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en
-~----------~----~----~----~------~----~------~--~---


Post Reply