THE MODEL EXCEEDS THE DEMO LIMITS

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

THE MODEL EXCEEDS THE DEMO LIMITS

Post by Archiver »



Hi,
I'm still working on the problem I have been asking so many
questions about. Following your advice I have reformulated the problem
and successfully compiled and run it. However, I got a "THE MODEL
EXCEEDS THE DEMO LIMITS".

As you said last time, multiplying indicator with the values I want to
minimize is not a good idea. And I wonder if you would be kind enough
to hint me some better ways.

Moreover, right now I'm testing the program with dummy data, so the
dimension you see in the program is really small. But the problem I
really want to solve involves:
set face_number /1*1000/;
set new_face_vector_length /1*100/;
set old_face_vector_length /1*200/;

So even if I improve my program, will the demo version of GAMS be able
to solve the problem? Or do I need to submit it to places like NEOS?


This is what my program look like right now:

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);
integer variable artificial_var1(face_number, face_number,
face_number);
integer variable artificial_var2(face_number, face_number,
face_number);
integer variable artificial_var3(face_number, face_number,
face_number);
integer variable artificial_var4(face_number, face_number,
face_number);

variable cost;

alias (face_number, f1, f2, f3, f4, f5, f6, f7, f8, f9);
alias (new_face_vector_length, n1, n2, n3, n4, n5, n6);
alias (old_face_vector_length, o1, o2, o3, o4, o5, o6);

equations cost_function;

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))));

equations filter_function1(f4, f5, f6), filter_function2(f4, f5, f6),
filter_function3(f4, f5, f6), filter_function4(f4, f5, f6),
filter_function5(f4, f5, f6);

filter_function1(f4, f5, f6) ..
sum(o2, power(face_vectors(f4, o2) - face_vectors(f6, o2), 2)) -
sum(o1, power(face_vectors(f4, o1) - face_vectors(f5, o1), 2))
=l= 50 * 5 * (1 - artificial_var1(f4, f5, f6));

filter_function2(f4, f5, f6) ..
sum(o4, power(face_vectors(f4, o4) - face_vectors(f6, o4), 2)) -
(-50 * 5 - 0.000001) * artificial_var2(f4, f5, f6)
=g= sum(o3, power(face_vectors(f4, o3) - face_vectors(f5, o3), 2)) +
0.000001;

filter_function3(f4, f5, f6) ..
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))
=l= 50 * 3 * (1 - artificial_var3(f4, f5, f6));

filter_function4(f4, f5, f6) ..
sum(n5, power(projected_face_vectors(f4, n5) -
projected_face_vectors(f5, n5), 2)) -
(-50 * 3 - 0.000001) * artificial_var4(f4, f5, f6)
=g= sum(n6, power(projected_face_vectors(f4, n6) -
projected_face_vectors(f6, n6), 2)) + 0.000001;


filter_function5(f4, f5, f6) ..
artificial_var1(f4, f5, f6) * artificial_var2(f4, f5, f6) *
artificial_var3(f4, f5, f6) * artificial_var4(f4, f5, f6)
=e= indicator(f4, f5, f6);


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

display M.l, M.m;


And my dummy testing data:

1 1 1.1
1 2 2.4
1 3 3.9
1 4 9.1
1 5 1.5

2 1 2.3
2 2 1.6
2 3 8.1
2 4 0.5
2 5 2.6

3 1 5.4
3 2 3.4
3 3 2.1
3 4 4.6
3 5 4.8

4 1 8.7
4 2 7.1
4 3 3.5
4 4 6.1
4 5 9.3

5 1 2.0
5 2 1.9
5 3 5.4
5 4 8.2
5 5 3.9

6 1 6.5
6 2 4.7
6 3 8.3
6 4 9.2
6 5 0.7

7 1 0.6
7 2 3.8
7 3 4.5
7 4 2.1
7 5 5.6

8 1 3.4
8 2 5.8
8 3 6.9
8 4 0.4
8 5 2.5

Many thanks to all the your help.
I truly appreciated it.


Eunice Chen
--~--~---------~--~----~------------~-------~--~----~
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: THE MODEL EXCEEDS THE DEMO LIMITS

Post by Archiver »



Eunice,

I don't think your new model has much to do with your original
problem. I refer to your original model where you wanted to minimize
the following objective (I abbreviated the variable and parameter
names):

cost =e= sum((f1, f2, f3)
$(sum(o1, sqr(fv(f1, o1) - fv(f2,o1))) >
sum(o1, sqr(fv(f1, o1) - fv(f3,o1))) and
sum(n1, sqr(pf(f1, n1) - pf(f2, n1)))
sum(o1, sqr(fv(f1, o1) - fv(f3,o1)))),

max(0,sum(n1, sqr(pf(f1, n1) - pf(f3, n1))) -
sum(n1, sqr(pf(f1, n1) - pf(f2, n1)))));

If you actually mean 'A-B positive', you cannot express this in a
mathematical program. MP only works with 'greater/less or equal than'.
Assuming again you mean A-B is not negative your model has a trivial
solution: pf=0.

Hope this helps,
Michael Bussieck - GAMSWorld Coordinator

On Sep 20, 8:46 am, lweunice wrote:
> > Hi,
> > I'm still working on the problem I have been asking so many
> > questions about. Following your advice I have reformulated the problem
> > and successfully compiled and run it. However, I got a "THE MODEL
> > EXCEEDS THE DEMO LIMITS".
> >
> > As you said last time, multiplying indicator with the values I want to
> > minimize is not a good idea. And I wonder if you would be kind enough
> > to hint me some better ways.
> >
> > Moreover, right now I'm testing the program with dummy data, so the
> > dimension you see in the program is really small. But the problem I
> > really want to solve involves:
> > set face_number /1*1000/;
> > set new_face_vector_length /1*100/;
> > set old_face_vector_length /1*200/;
> >
> > So even if I improve my program, will the demo version of GAMS be able
> > to solve the problem? Or do I need to submit it to places like NEOS?
> >
> > This is what my program look like right now:
> >
> > 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);
> > integer variable artificial_var1(face_number, face_number,
> > face_number);
> > integer variable artificial_var2(face_number, face_number,
> > face_number);
> > integer variable artificial_var3(face_number, face_number,
> > face_number);
> > integer variable artificial_var4(face_number, face_number,
> > face_number);
> >
> > variable cost;
> >
> > alias (face_number, f1, f2, f3, f4, f5, f6, f7, f8, f9);
> > alias (new_face_vector_length, n1, n2, n3, n4, n5, n6);
> > alias (old_face_vector_length, o1, o2, o3, o4, o5, o6);
> >
> > equations cost_function;
> >
> > 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))));
> >
> > equations filter_function1(f4, f5, f6), filter_function2(f4, f5, f6),
> > filter_function3(f4, f5, f6), filter_function4(f4, f5, f6),
> > filter_function5(f4, f5, f6);
> >
> > filter_function1(f4, f5, f6) ..
> > sum(o2, power(face_vectors(f4, o2) - face_vectors(f6, o2), 2)) -
> > sum(o1, power(face_vectors(f4, o1) - face_vectors(f5, o1), 2))
> > =l= 50 * 5 * (1 - artificial_var1(f4, f5, f6));
> >
> > filter_function2(f4, f5, f6) ..
> > sum(o4, power(face_vectors(f4, o4) - face_vectors(f6, o4), 2)) -
> > (-50 * 5 - 0.000001) * artificial_var2(f4, f5, f6)
> > =g= sum(o3, power(face_vectors(f4, o3) - face_vectors(f5, o3), 2)) +
> > 0.000001;
> >
> > filter_function3(f4, f5, f6) ..
> > 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))
> > =l= 50 * 3 * (1 - artificial_var3(f4, f5, f6));
> >
> > filter_function4(f4, f5, f6) ..
> > sum(n5, power(projected_face_vectors(f4, n5) -
> > projected_face_vectors(f5, n5), 2)) -
> > (-50 * 3 - 0.000001) * artificial_var4(f4, f5, f6)
> > =g= sum(n6, power(projected_face_vectors(f4, n6) -
> > projected_face_vectors(f6, n6), 2)) + 0.000001;
> >
> > filter_function5(f4, f5, f6) ..
> > artificial_var1(f4, f5, f6) * artificial_var2(f4, f5, f6) *
> > artificial_var3(f4, f5, f6) * artificial_var4(f4, f5, f6)
> > =e= indicator(f4, f5, f6);
> >
> > Model new_projection_space /all/ ;
> > Solve new_projection_space using minlp minimizing cost ;
> >
> > display M.l, M.m;
> >
> > And my dummy testing data:
> >
> > 1 1 1.1
> > 1 2 2.4
> > 1 3 3.9
> > 1 4 9.1
> > 1 5 1.5
> >
> > 2 1 2.3
> > 2 2 1.6
> > 2 3 8.1
> > 2 4 0.5
> > 2 5 2.6
> >
> > 3 1 5.4
> > 3 2 3.4
> > 3 3 2.1
> > 3 4 4.6
> > 3 5 4.8
> >
> > 4 1 8.7
> > 4 2 7.1
> > 4 3 3.5
> > 4 4 6.1
> > 4 5 9.3
> >
> > 5 1 2.0
> > 5 2 1.9
> > 5 3 5.4
> > 5 4 8.2
> > 5 5 3.9
> >
> > 6 1 6.5
> > 6 2 4.7
> > 6 3 8.3
> > 6 4 9.2
> > 6 5 0.7
> >
> > 7 1 0.6
> > 7 2 3.8
> > 7 3 4.5
> > 7 4 2.1
> > 7 5 5.6
> >
> > 8 1 3.4
> > 8 2 5.8
> > 8 3 6.9
> > 8 4 0.4
> > 8 5 2.5
> >
> > Many thanks to all the your help.
> > I truly appreciated it.
> >
> > Eunice Chen
--~--~---------~--~----~------------~-------~--~----~
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: THE MODEL EXCEEDS THE DEMO LIMITS

Post by Archiver »



Your reformulation is MUCH BETTER. I truly appreciated it.

And A-B is positive is basically the same as A-B is not negative in
this case, because the result of the summations should be the same
(unless there are some precision issues.)
I knew that with A-B is not negative, the answer is 0.
In fact, there should be another constraint. I didn't put it inside
because someone had solved this problem (using a method that I thought
to be wrong) without the constraint and got an answer that is not 0. I
kind of wanted to make sure that I'm not making the same mistake and
so I would like to see the answer to be 0 without the constraint.

The extra constraint is norm = 1 (the norm here I define it as the
squared sum of each row of the target matrix)
So now my code looks like:
(With only 2 extra lines:
equations norms(n5);
norms(n5) .. sum(o3, power(M(n5, o3), 2)) =e= 1.0;)

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));

variable cost;
alias (face_number, f1, f2, f3);
alias (old_face_vector_length, o1, o2, o3);
alias (new_face_vector_length, n1, n2, n3, n4, n5);
equations cost_function;
cost_function ..
cost =e= sum((f1, f2, f3)
$(sum(o1, power(face_vectors(f1, o1) - face_vectors(f2,
o1), 2)) >
sum(o2, power(face_vectors(f1, o2) - face_vectors(f3,
o2), 2))),
max(0,
sum(n3, power(projected_face_vectors(f1, n3) -
projected_face_vectors(f3, n3), 2)) -
sum(n4, power(projected_face_vectors(f1, n4) -
projected_face_vectors(f2, n4), 2))));

equations norms(n5);
norms(n5) .. sum(o3, power(M(n5, o3), 2)) =e= 1.0;

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

display M.l, M.m;


But now the solver says:

The model has 40 variables and 28 constraints
with 184 Jacobian elements, 39 of which are nonlinear.
The Hessian of the Lagrangian has 39 elements on the diagonal,
276 elements below the diagonal, and 39 nonlinear variables.

** Infeasible solution. Reduced gradient less than tolerance.


** Warning ** All Jacobian elements in the rows marked below are
less than the absolute pivot tolerance 1.0E-10
(Rtpiva)
in the final point. Only slacks or artificials can
be basic in these rows.
A better scaling or better bounds on the variables
may help the optimization.

norms(1): Infeasible row with only small Jacobian elements.
norms(2): Infeasible row with only small Jacobian elements.
norms(3): Infeasible row with only small Jacobian elements.

Again, would you be kind enough to tell me what this means but how I
might be able to fix my formulation.

Many Thanks.

Eunice Chen
--~--~---------~--~----~------------~-------~--~----~
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: THE MODEL EXCEEDS THE DEMO LIMITS

Post by Archiver »



Eunice,

The model is non-convex and the derivatives are non-smooth (because of
the max). Finding a global optimum for this you need a global solver.
LindoGlobal is the only solver in the GAMS portfolio that can handle
this. If you don't have a license you can try to use NEOS (http://www-
neos.mcs.anl.gov/neos/solvers/go:LINDOGlobal/GAMS.html). You can also
try a local solver like Conopt, but you need to provide a good
starting point. I just did

M.l(n1,o1) = uniform(-1,1);
pf.l(f1,n1) = uniform(-1,1);

before the solve and Conopt also found a solution close to zero
(including the norm constraint).

Hope this helps,
Michael Bussieck - GAMSWorld Coordinator

On Oct 1, 11:18 am, lweunice wrote:
> > Your reformulation is MUCH BETTER. I truly appreciated it.
> >
> > And A-B is positive is basically the same as A-B is not negative in
> > this case, because the result of the summations should be the same
> > (unless there are some precision issues.)
> > I knew that with A-B is not negative, the answer is 0.
> > In fact, there should be another constraint. I didn't put it inside
> > because someone had solved this problem (using a method that I thought
> > to be wrong) without the constraint and got an answer that is not 0. I
> > kind of wanted to make sure that I'm not making the same mistake and
> > so I would like to see the answer to be 0 without the constraint.
> >
> > The extra constraint is norm = 1 (the norm here I define it as the
> > squared sum of each row of the target matrix)
> > So now my code looks like:
> > (With only 2 extra lines:
> > equations norms(n5);
> > norms(n5) .. sum(o3, power(M(n5, o3), 2)) =e= 1.0;)
> >
> > 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));
> >
> > variable cost;
> > alias (face_number, f1, f2, f3);
> > alias (old_face_vector_length, o1, o2, o3);
> > alias (new_face_vector_length, n1, n2, n3, n4, n5);
> > equations cost_function;
> > cost_function ..
> > cost =e= sum((f1, f2, f3)
> > $(sum(o1, power(face_vectors(f1, o1) - face_vectors(f2,
> > o1), 2)) >
> > sum(o2, power(face_vectors(f1, o2) - face_vectors(f3,
> > o2), 2))),
> > max(0,
> > sum(n3, power(projected_face_vectors(f1, n3) -
> > projected_face_vectors(f3, n3), 2)) -
> > sum(n4, power(projected_face_vectors(f1, n4) -
> > projected_face_vectors(f2, n4), 2))));
> >
> > equations norms(n5);
> > norms(n5) .. sum(o3, power(M(n5, o3), 2)) =e= 1.0;
> >
> > Model new_projection_space /all/ ;
> > Solve new_projection_space using minlp minimizing cost ;
> >
> > display M.l, M.m;
> >
> > But now the solver says:
> >
> > The model has 40 variables and 28 constraints
> > with 184 Jacobian elements, 39 of which are nonlinear.
> > The Hessian of the Lagrangian has 39 elements on the diagonal,
> > 276 elements below the diagonal, and 39 nonlinear variables.
> >
> > ** Infeasible solution. Reduced gradient less than tolerance.
> >
> > ** Warning ** All Jacobian elements in the rows marked below are
> > less than the absolute pivot tolerance 1.0E-10
> > (Rtpiva)
> > in the final point. Only slacks or artificials can
> > be basic in these rows.
> > A better scaling or better bounds on the variables
> > may help the optimization.
> >
> > norms(1): Infeasible row with only small Jacobian elements.
> > norms(2): Infeasible row with only small Jacobian elements.
> > norms(3): Infeasible row with only small Jacobian elements.
> >
> > Again, would you be kind enough to tell me what this means but how I
> > might be able to fix my formulation.
> >
> > Many Thanks.
> >
> > Eunice Chen
--~--~---------~--~----~------------~-------~--~----~
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