# \[AMPL 24509\] Fix command

**URL:** <https://discuss.ampl.com/t/ampl-24509-fix-command/359>\
**Category:** Google Group Mirror\
**Created:** [February 4, 2023, 10:22pm UTC](https://discuss.ampl.com/t/ampl-24509-fix-command/359 "2023-02-04T22:22:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jairo.yumbla](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/jairo.yumbla/32/461_2.png) [@jairo.yumbla](https://discuss.ampl.com/u/jairo.yumbla)\
**Post date:** [February 4, 2023, 10:22pm UTC](https://discuss.ampl.com/t/ampl-24509-fix-command/359/1 "2023-02-04T22:22:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AMPL\_Google\_Group](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@AMPL\_Google\_Group](https://discuss.ampl.com/u/AMPL_Google_Group)\
**Post date:** [February 6, 2023, 12:27am UTC](https://discuss.ampl.com/t/ampl-24509-fix-command/359/2 "2023-02-06T00:27:47Z")

</div>

See the answer at [https://discuss.ampl.com/t/fix-command-on-binary-variables/360/2](https://discuss.ampl.com/t/fix-command-on-binary-variables/360/2) in the new [AMPL Forum](https://discuss.ampl.com/).
