# Decision Optimization

View Only

## How to develop these constrains and conditions in cplex?

• #### 1.  How to develop these constrains and conditions in cplex?

Posted Sat December 17, 2022 03:40 PM
Edited by System Fri January 20, 2023 04:42 PM

It took me many days to develop the remaining part of my code, the remainig two decision variable:
(1) beam_reuse[beams]
(2) beam_pol[beams]

I want to write these constrains:
(1) for beam_reuse:
i have 2 reuses so will distribute the beams in the 4 rows on these two reuses the beams in the first two rows (first 12 beams) will take reuse[1] =1, and the beams in the last two rows ( last 9 beams) will take reuse[2]=2.

why 2? because we have two polarization in each reuse, for example if we have 3 polarization then the beams in the first three rows will take reuse[1], and the beams in the other 3 rows will take reuse[2].

(2) beam_pol:
i have two polarization for each reuse, so the beams in the first row ( first 6 beams) will take pol[0]=0 and the beams in the second row (second 6 beams) will take pol[1]=1, and the beams in the third next [6 beams] will again take pol[0]=1 but here we have changed the reuse in the above to be 2 not 1 and the beams in the last row (last 3 beams) will take pol[1]=1 again.

``````int Nchannels=16;
range channels=1.. Nchannels;

int Npol=2;                        // may be 3 or 4 or .....
range pol= 0..Npol-1;
int polarization [i in pol]=i;

int Nreuse=2;                     // may be 1 or 3 or 4 or .....
range reusee= 1..Nreuse;
int reuse [i in reusee]=i;

int Nrows= Npol*Nreuse;
range rows=1..Nrows;

int TotChannels = Nchannels *Npol*Nreuse;

dvar int first_beam_in_each_row[rows]         in (1..Nbeams);
dvar int No_beams_in_each_row[rows]         in (0..Nbeams);
dvar int beam_firstchannel[beams]           in   (channels);
dvar int beam_nomusedchannel[beams]         in   (channels);

dvar int beam_reuse[beams]                  in    (reuse);
dvar int beam_pol[beams]                    in    (pol);

//and my code has the following output:

//Nrows=4;
//Nbeams=21;
//first_beam_in_each_row=[1,7,13,19];
//No_beams_in_each_row=[6,6,6,3];
//beam_firstchannel=[1,3,5,7,9,11,1,3,5,7,9,11,1,3,5,7,9,11,1,6,11];
//beam_nomusedchannel=[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,5,5,5];
``````

------------------------------
Mohamed Mandour
------------------------------
#DecisionOptimization

• #### 2.  RE: How to develop these constrains and conditions in cplex?

Posted Sat December 17, 2022 04:00 PM
@ALEX FLEISCHER Could you help please ? ​

------------------------------
Mohamed Mandour
------------------------------

• #### 3.  RE: How to develop these constrains and conditions in cplex?

Posted Sun December 18, 2022 09:15 AM
similar question at https://stackoverflow.com/questions/74833832/ihow-to-develop-these-constrains-and-conditions-in-cplex/74840219#74840219

``````     int Nbeams=21;
int x=1;
range beams=x..Nbeams;

int Nchannels=16;
range channels=1.. Nchannels;

int Npol=2;                        // may be 3 or 4 or .....
range pol= 0..Npol-1;
int polarization [i in pol]=i;

int Nreuse=2;                     // may be 1 or 3 or 4 or .....
range reusee= 1..Nreuse;
int reuse [i in reusee]=i;

int Nrows= Npol*Nreuse;
range rows=1..Nrows;

int TotChannels = Nchannels *Npol*Nreuse;

dvar int first_beam_in_each_row[rows]         in (1..Nbeams);
dvar int No_beams_in_each_row[rows]         in (0..Nbeams);
dvar int beam_firstchannel[beams]           in   (channels);
dvar int beam_nomusedchannel[beams]         in   (channels);

dvar int beam_reuse[beams]             in    (reusee);
dvar int beam_pol[beams]                   in    (pol);

subject to
{
forall(i in beams) (i<=first_beam_in_each_row[3]-1) => (beam_reuse[i]==1);
forall(i in beams) (i>=first_beam_in_each_row[3]) => (beam_reuse[i]==2);

forall(r in rows:r!=1)
forall(i in beams) ((i>=first_beam_in_each_row[r-1]) && (i<=first_beam_in_each_row[r]-1)) => (beam_pol[i]==1-r mod 2);

}​``````

------------------------------
[Alex] [Fleischer]
[Data and AI Technical Sales]
[IBM]
------------------------------