# [AMPL 24567] condition

Hello
Could someone help me to solve this issue please,

I have 7 devices, each device represents with a letter g, and the device that is neighbor to it represents with a latter gu.

Devices 1 to 4 are transmitters, devices 5 and 6 are switches, and device number 7 is controller . Device No. 1 can send to device No. 2 via device No. 5, and device No. 2 has a direct link that it can send to device No. 3 without any switch. Device No. 3 sends to device No. 4 through device No. 6. Device No. 1 can send It is sent to device No. 4 through device No. 7. Device No. 1 and 2 are a group in the same group connect together by device no 5. And the devices.Device No. 3 and 4 are anther group in the same group connect with device NO 6

Here is a summary of the connections between the devices:

Device 1 can send data to Device 2 through Device 5.
Device 2 can send data directly to Device 3.
Device 3 can send data to Device 4 through Device 6.
Device 1 can send data to Device 4 through Device 7.
Devices 1 and 2 are in the same group, connected by Device 5.
Devices 3 and 4 are in the same group, connected by Device 6.

There is a amount of data traffic being sent and receive between them.

in AMPL i have represents them like this:
var E{g in G,gu in GU[g]}binary;# =1 if the phat between g and neighbor gu is active otherwise = 0
paramD >=0; #large number
param o integer > 0;
set R within {1…o, 1…o};
param wer{R};

#dataTraffic variable has a value (Traffic Value) if there is a traffic between g and gu and otherwise (if there is no traffic between g and gu) dataOutput=0
var data_Traffic{g in G, gu in GU[g]}>=0; # amount of traffics between two devices g and gu
s.t. data_Path1 {g in G, gu in GU[g]}:data_Traffic[g,gu]<= D* E[g,gu];
s.t. data_Path2 {g in G, gu in GU[g]}:D*data_Traffic[g,gu]>=E[g,gu];
#data Path Capacity
s.t. data_Path_Capacity {g in G,gu in GU[g]}: data_Traffic[g,gu]<=E[g,gu]*wer[g,gu];

in data file I have:
param: R:
wer
[,]:
1 2 3 4 5 6 7 :=
1 . . . . 25 . 30
2 . . 25 . 25 . .
3 . 25 . . . 25 .
4 . . . . . 25 30
5 25 25 . . . . .
6 . . 25 25 . . .
7 30 . . 30 . . . ;

The problem is that every time the model chooses to communicate only from device number two to three. Even if this link consume higest power consumation . I want it to choose the path that does not spend more energy. Can someone help me formulate this condition?

بتاريخ الأحد، 12 مارس 2023، جاء من Rahaf <tamara.73zhro@gmail.com>:

I cannot reproduce the problem you are seeing, because you are not providing definitions and data for G and GU. However, I notice that your AMPL model does not have an objective function. Thus the solver will return the first solution to the constraints that it finds, and that may not be the solution that you want.

Using a “minimize” statement, you could tell AMPL to minimize an expression that represents the total power consumption. (I cannot say what that expression should be, however, since I am not familiar with the whole application. You will have to use your knowledge of the application to determine an expression for total power consumption.)