Fix command on binary variables

Hi everyone,

I’m using the fix command to determine a value of a binary variable as follows:

for {i in BusBat,(t,s) in SC: 3 < t <= 5} {fix ch[i,t,s] := 0;}
for {i in BusBat,(t,s) in SC: 0 <= t <= 3 && 6 <= t <= 11} {fix ch[i,t,s] := 1;}

the command doesn’t work however. it is supposed that variable ‘ch’ has to be 0 when 3 < t <= 5 only, but it doesn’t happen at any BusBat.

The obtained results are:

t BusBat[11] BusBat[32] BusBat[58]

0 [ch:1] [ch:1] [ch:1]
1 [ch:1] [ch:1] [ch:0]
2 [ch:1] [ch:1] [ch:0]
3 [ch:1] [ch:1] [ch:0]
4 [ch:0] [ch:0] [ch:0]
5 [ch:0] [ch:0] [ch:0]
6 [ch:0] [ch:1] [ch:0]
7 [ch:0] [ch:1] [ch:0]
8 [ch:1] [ch:1] [ch:0]
9 [ch:1] [ch:1] [ch:0]
10 [ch:1] [ch:1] [ch:1]
11 [ch:1] [ch:1] [ch:1]

I formuled the command as follows too, but again it doesn’t work.

fix {i in BusBat,(t,s) in SC: 3 <= t <= 5} e_sd[i,t,s] := 0;
fix {i in BusBat,(t,s) in SC: 0 <= t < 3 && 6 <= t <= 11} e_sd[i,t,s] := 1;

I anticipate my thanks for the help.

There is no value of t that satisfies “0 <= t < 3 && 6 <= t <= 11”. I think instead you want to use the || (or) operator:

fix {i in BusBat,(t,s) in SC: 3 <= t <= 5} e_sd[i,t,s] := 0;
fix {i in BusBat,(t,s) in SC: 0 <= t < 3 || 6 <= t <= 11} e_sd[i,t,s] := 1;