Caution: 0-dimensional slice

531 views
Skip to first unread message

renan

unread,
May 14, 2015, 12:17:18 PM5/14/15
to am...@googlegroups.com
Hello Mr. Fourier

I'm glad to join the group...

could you please give me an idea why im getting this caution...
any help would mean a lot.

----------------------------------------------------------------------------
set PRODUCT   ;
set CROSS := {i in PRODUCT, j in PRODUCT}
param phi {CROSS} ;

maximize PROFIT:
sum {i in PRODUCT}alpha[i]*width[i]^beta[i]*
prod{(i,j) in CROSS} width[j]^phi[i,j]*

(
(selling[i]-unit[i]-replenish[i])*choose[i]*(facings[i])^beta[i]* 
prod{(i,j) in CROSS} facings[j]^phi[i,j]-

(restock[i]/hold[i])*choose[i]*(facings[i])^beta[i]-1*
prod{(i,j) in CROSS} facings[j]^phi[i,j]
)

- sum {i in PRODUCT} ((holding[i]*choose[i]*facings[i])-fixed*choose[i])




irion.txt, line 39 (offset 1031):
Caution: 0-dimensional slice
context:  prod{(i,j) in  >>> CROSS} <<<  facings[j]^phi[i,j]-

irion.txt, line 42 (offset 1133):
Caution: 0-dimensional slice
context:  prod {(i,j) in  >>> CROSS} <<<  facings[j]^phi[i,j]
ampl: 

renan

unread,
May 14, 2015, 12:24:39 PM5/14/15
to am...@googlegroups.com
Apologies, Mr. Fourer i mean...
ive been trying all possibilities on this for hours
could you shed some light please...many thanks

Robert Fourer

unread,
May 15, 2015, 10:01:30 AM5/15/15
to am...@googlegroups.com
Your 2nd and 3rd "prod {(i,j) in CROSS}" are part of what is being multiplied by the first "prod {(i,j) in CROSS}". Thus you are trying to index over {(i,j) in CROSS} when both i and j are already defined, which is the reason for the "0-dimensional slice" warning. To keep the first product from extending to the others, you can parenthesize it:

maximize PROFIT:
sum {i in PRODUCT} alpha[i] * width[i]^beta[i] *
(prod {(i,j) in CROSS} width[j]^phi[i,j]) * (...

If not parenthesized in this way, sums and products apply to everything until the next + sign.

Bob Fourer
am...@googlegroups.com

=======

renan maglasang

unread,
May 15, 2015, 10:17:48 AM5/15/15
to am...@googlegroups.com
Dear Mr. Fourer,

I thank you very much....its solved. its solved.

--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/aKsh2MUKE4o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.

renan maglasang

unread,
May 20, 2015, 1:58:21 AM5/20/15
to am...@googlegroups.com
Hello Mr. Fourer

again...any help on this...

i want that if choose=0, facings would be equals to 1...

(this is to avoid my objective function from being zero since its involves crossproduct)
i believe the constraint below would make this way possible but my question is why AMPL gives infeasible solution?

var facings {i in PRODUCT} >=0 integer; 
var choose {i in PRODUCT} >=0 binary ;

subject to POSITIVEINT{i in PRODUCT}:
(width[i]*facings[i]-width[i])*(width[i]*choose[i]+width[i]) >= 0;



renan maglasang

unread,
May 20, 2015, 8:01:18 AM5/20/15
to am...@googlegroups.com
​oops correction for my constraints...should be all minus width...
however, still it didnt work...

im not sure but is setting:​
var choose {i in PRODUCT} >=1 binary ;
a valid circumvention to my original intention?

Robert Fourer

unread,
May 20, 2015, 6:57:17 PM5/20/15
to am...@googlegroups.com
It is best to implement logic with linear rather than quadratic constraints. You might write

facings[i] >= 1 - choose[i]

to force facings[i] >= 1 when choose[i] = 0. If in fact you need to have facings[i] = 1 when choose[i] = 0, then you could also specify a constraint like

facings[i] <= 1 + U[i]*choose[i]

where U is an upper bound on the value of facings[i]-1. (When choose[i] = 1, these constraints have no effect.)

Bob Fourer
am...@googlegroups.com

=======
Reply all
Reply to author
Forward
0 new messages