SETS
u /1*10/
g /1*10/
r /1*10/
alias (u, uu)
PARAMETERS
X(g)
/1 7833.9
2 7878.4
3 7923.1
4 7967.9
5 8012.8
6 8057.9
7 8103.1
8 8148.4
9 8193.8
10 8239.4/
TABLE K(u,r)
1 2 3 4 5 6 7 8 9 10
1 110.9400 14.9427 21.7730 107.2948 86.9236 125.0415 77.2769 6.1595 65.2744 69.2062
2 72.1302 29.9665 21.6391 68.1248 51.2225 104.7691 38.0046 45.6546 89.4309 96.1623
3 51.6516 85.7474 77.7240 45.9884 12.5615 68.0209 29.3910 104.6288 124.8867 133.6660
4 18.6930 87.6248 79.0042 12.9272 36.0464 102.6715 23.7207 104.0261 140.1129 148.1111
5 149.9144 51.5421 58.7101 145.1611 109.8199 117.6701 110.0344 47.8352 14.6947 17.2627
6 57.2379 63.7732 55.7863 51.4801 9.4583 71.6139 18.8240 82.6829 105.7415 114.2755
7 16.7268 94.6529 86.0239 11.2187 38.6391 102.8906 29.8788 111.2612 146.0569 154.1810
8 120.0266 109.5562 105.3934 114.3869 68.6970 1.4035 89.8570 126.8826 111.1759 119.8896
9 163.6616 72.2187 77.9784 158.4782 117.7992 110.2387 122.4623 72.2097 10.9076 13.8980
10 98.5979 4.8997 7.0084 94.6127 72.1435 112.3654 63.2092 20.1245 67.6600 73.2183
PARAMETER Mat(u,g,r); Mat(u,g,r) = 1/(X(g)*power(K(u,r),3));
VARIABLES
B(u,g,r)
OBJ
nonnegative VARIABLE B
EQUATIONS
CONSTRAINT1
CONSTRAINT2(u)
OBJECTIVE;
CONSTRAINT1.. SUM((u,g,r),B(u,g,r)) =L= 3;
CONSTRAINT2(u) .. prod(g$(SUM(r,B(u,g,r)) ne 0),0.0024+SUM(r,SUM(uu$(ORD(uu) NE ORD(u)),B(uu,g,r)*Mat(uu,g,r))) /(SUM(r,B(u,g,r)*Mat(u,g,r))) ) =L= 1;
OBJECTIVE .. OBJ =E= prod(u, prod(g,0.0024+SUM(r,SUM(uu$(ORD(uu) NE ORD(u)),B(uu,g,r)*Mat(uu,g,r))) /(SUM(r,B(u,g,r)*Mat(u,g,r))) ));
MODEL Untitled_6 / CONSTRAINT1, CONSTRAINT2, OBJECTIVE /
SOLVE Untitled_6 USING NLP Minimizing OBJ
I get this error:
endogenous relational operations require model type "dnlp"
and I know that's because I shouldn't include a variable in the dollar sign, however it's crucial to me that for any u and g whenever this term:
SUM(r,B(u,g,r)*Mat(u,g,r)) is equal 0
this whole term:
0.0024+SUM(r,SUM(uu$(ORD(uu) NE ORD(u)),B(uu,g,r)*Mat(uu,g,r))) /(SUM(r,B(u,g,r)*Mat(u,g,r))) is excluded from the product
exclude expression from product if denumerator = 0

 User
 Posts: 4
 Joined: 10 months ago
Re: exclude expression from product if denumerator = 0
Hi
You could define a share as follows:
Note, that I moved the divisor to the left, so you won't have problems when the value of the divisor would be zero.
Now, you can use SHARE in your objective function.
Hope this helps
Renger
BTW:
* If you post, it is better for us, if you put your code in a code block in the post, so we can easily copypaste your code. Otherwise the alignment of the tables is lost.
You could define a share as follows:
Code: Select all
defshare(u,g)..
SHARE(u,g) * sum(r, B(u,g,r) * mat(u,g,r)) =E= sum(r, sum(uu$(ord(uu) ne ord(u)),
B(uu,g,r) * ,mat(uu,g,r))) ;
Now, you can use SHARE in your objective function.
Hope this helps
Renger
BTW:
* If you post, it is better for us, if you put your code in a code block in the post, so we can easily copypaste your code. Otherwise the alignment of the tables is lost.

 User
 Posts: 4
 Joined: 10 months ago
Re: exclude expression from product if denumerator = 0
Thanks a lot for your note,
I just don't get what you're proposing, what is share(u,g) ? why should I multiply it by these terms ?
if you mean that I should write this :
on two steps, share(u,g) then multiply on g that's ok but still my problem is that I want to multiply this expression on g when the denumerator is not equal 0 and remove this expression as a whole (numerator and denumerator) from the product when the denumerator is equal 0
I just don't get what you're proposing, what is share(u,g) ? why should I multiply it by these terms ?
if you mean that I should write this :
Code: Select all
CONSTRAINT2(u) ..prod(g$(SUM(r,B(u,g,r)) ne 0),0.0024+SUM(r,SUM(uu$(ORD(uu) NE ORD(u)),B(uu,g,r)*Mat(uu,g,r))) /(SUM(r,B(u,g,r)*Mat(u,g,r))) ) =L= 1;
Re: exclude expression from product if denumerator = 0
Here you go
Code: Select all
variables
B(u,g,r)
OBJ
SHARE(u,g)
;
nonnegative variable B
equations
constraint1
constraint2(u)
defshare(u,g)
objective;
constraint1..
sum((u,g,r), B(u,g,r)) =L= 3;
constraint2(u)..
prod(g, 0.0024 +
sum(r, sum(uu$(ord(uu) ne ord(u)), share(u,g) ))) =L= 1;
defshare(u,g)..
share(u,g) * sum(r, B(u,g,r) * mat(u,g,r)) =e=
sum(r, sum(uu$(ord(uu) ne ord(u)), B(uu,g,r) * mat(uu,g,r))) ;
objective..
OBJ =e= prod(u, prod(g, 0.0024 + SHARE(u,g) ));
MODEL Untitled_6 / constraint1, constraint2, defshare, objective /
solve Untitled_6 using nlp minimizing OBJ;

 User
 Posts: 4
 Joined: 10 months ago
Re: exclude expression from product if denumerator = 0
Thank you very much for your help!
this down here (as you suggested) is exactly what I need :
However, I have a question in defshare(u,g), I can't understand what value would share(u,g) have if sum(r, B(u,g,r) * GMat(u,g,r)) is equal 0.
The equation will be: share(u,g)*0 = 0
Kindly note that If this prevents sum(r, B(u,g,r) * GMat(u,g,r)) from ever being equal to zero then that would violate the problem. what I need is for this term to be allowed to be equal 0 for sum u,g combinations and whenever this happens, I need to not include the share(u,g) in the product over g part or to make its value equal 1 as if I excluded it from the product.
Thanks a lot for your help!
this down here (as you suggested) is exactly what I need :
Code: Select all
variables
B(u,g,r)
OBJ
SHARE(u,g)
;
nonnegative variable B
equations
constraint1
constraint2(u)
defshare(u,g)
objective;
constraint1..
sum((u,g,r), B(u,g,r)) =L= 3;
defshare(u,g)..
SHARE(u,g) * sum(r, B(u,g,r) * GMat(u,g,r)) =e=
sum(r,0.0024 + sum(uu$(ord(uu) ne ord(u)), B(uu,g,r) * GMat(uu,g,r))) ;
constraint2(u)..
prod(g, share(u,g)) =L= 1;
objective..
OBJ =e= prod(u, prod(g, SHARE(u,g) ));
MODEL Untitled_6 / constraint1, constraint2, defshare, objective /
solve Untitled_6 using nlp minimizing OBJ;
The equation will be: share(u,g)*0 = 0
Kindly note that If this prevents sum(r, B(u,g,r) * GMat(u,g,r)) from ever being equal to zero then that would violate the problem. what I need is for this term to be allowed to be equal 0 for sum u,g combinations and whenever this happens, I need to not include the share(u,g) in the product over g part or to make its value equal 1 as if I excluded it from the product.
Thanks a lot for your help!

 User
 Posts: 4
 Joined: 10 months ago
Re: exclude expression from product if denumerator = 0
Also I'd be very glad if you could help me with this:
I tried to run it and observed the output ( which is infeasible although I have a guaranteed feasible scenario ), I found that:
All this makes sense except the fact that B(1,2,1) till B(1,2,6) are multiplied by 0, where G(1,2,1) till G(1,2,6) are not =0 as seen here:
And also share(1,2) isn't directly multiplied by their summation as stated in the objective function here:
Kindly note that this is the final version of the problem, the only missing part is excluding the shares whose denumerator is = 0 from the product over g or making them = 1 in order not to affect the product.
Final version:
I tried to run it and observed the output ( which is infeasible although I have a guaranteed feasible scenario ), I found that:
Code: Select all
defshare(1,2).. (0)*B(1,2,1) + (0)*B(1,2,2) + (0)*B(1,2,3) + (0)*B(1,2,4)
+ (0)*B(1,2,5) + (0)*B(1,2,6)  0.929602939765741*B(2,2,1)
 380.429985799305*B(2,2,2)  122.972260208815*B(2,2,3)
 1.0276043863363*B(2,2,4)  1.93263063394285*B(2,2,5)
 0.649231298767336*B(2,2,6)  0.929602939765741*B(3,2,1)
 380.429985799305*B(3,2,2)  122.972260208815*B(3,2,3)
 1.0276043863363*B(3,2,4)  1.93263063394285*B(3,2,5)
 0.649231298767336*B(3,2,6)  0.929602939765741*B(4,2,1)
 380.429985799305*B(4,2,2)  122.972260208815*B(4,2,3)
 1.0276043863363*B(4,2,4)  1.93263063394285*B(4,2,5)
 0.649231298767336*B(4,2,6)  0.929602939765741*B(5,2,1)
 380.429985799305*B(5,2,2)  122.972260208815*B(5,2,3)
 1.0276043863363*B(5,2,4)  1.93263063394285*B(5,2,5)
 0.649231298767336*B(5,2,6)  0.929602939765741*B(6,2,1)
 380.429985799305*B(6,2,2)  122.972260208815*B(6,2,3)
 1.0276043863363*B(6,2,4)  1.93263063394285*B(6,2,5)
 0.649231298767336*B(6,2,6) + (0)*SHARE(1,2) =E= 24000000 ;
(LHS = 0, INFES = 24000000 ****)
Code: Select all
 31 PARAMETER GMat
1 2 3 4 5 6
1.1 0.935 382.591 123.671 1.033 1.944 0.653
1.2 0.930 380.430 122.972 1.028 1.933 0.649
1.3 0.924 378.284 122.278 1.022 1.922 0.646
1.4 0.919 376.157 121.591 1.016 1.911 0.642
1.5 0.914 374.049 120.910 1.010 1.900 0.638
1.6 0.909 371.955 120.233 1.005 1.890 0.635
1.7 0.904 369.881 119.562 0.999 1.879 0.631
Code: Select all
defshare(u,g)..
(SHARE(u,g)*(sum(r, B(u,g,r) * GMat(u,g,r)))) =e=
0.0024*power(10,10)+sum(r, sum(uu$(ord(uu) ne ord(u)), B(uu,g,r) * GMat(u,g,r))) ;
Final version:
Code: Select all
SETS
u users /1*6/
g resources /1*7/
r antennas /1*6/
alias (u, uu)
PARAMETERS
X(g) term related to lambda
/1 7833.9
2 7878.4
3 7923.1
4 7967.9
5 8012.8
6 8057.9
7 8103.1/
TABLE D(u,r)
1 2 3 4 5 6
1 110.9400 14.9427 21.7730 107.2948 86.9236 125.0415
2 72.1302 29.9665 21.6391 68.1248 51.2225 104.7691
3 51.6516 85.7474 77.7240 45.9884 12.5615 68.0209
4 18.6930 87.6248 79.0042 12.9272 36.0464 102.6715
5 149.9144 51.5421 58.7101 145.1611 109.8199 117.6701
6 57.2379 63.7732 55.7863 51.4801 9.4583 71.6139
PARAMETER GMat(u,g,r); GMat(u,g,r) = (1/(X(g)*power(D(u,r),3)))*power(10,10);
display GMat ;
variables
B(u,g,r)
OBJ
SHARE(u,g)
;
nonnegative variable B
equations
constraint1
defshare(u,g)
constraint2(u)
objective;
constraint1..
sum((u,g,r), B(u,g,r)) =L= 3;
defshare(u,g)..
(SHARE(u,g)*(sum(r, B(u,g,r) * GMat(u,g,r)))) =e=
0.0024*power(10,10)+sum(r, sum(uu$(ord(uu) ne ord(u)), B(uu,g,r) * GMat(u,g,r))) ;
constraint2(u)..
prod(g, share(u,g)) =L= 1;
objective..
OBJ =e= prod(u, prod(g, SHARE(u,g) ));
MODEL Untitled_6 / constraint1, constraint2, defshare, objective /
solve Untitled_6 using nlp minimizing OBJ;