Dear all,

I have to avoid multiplication of continuous and integer variables. For this, linearization strategy is used, but the formulation is not working as needed in the attached model. Would you please take a look at the codes and help in correcting the codes?

Linearization of continuous and Integer variable.gms (2.67 KB)

Best regards,

David

David,

Your binary expansion of integer variable is wrong.

You have to understand how the expansion of integer variables to binary variables works before you implement this.

Let’s say your integer variables go from 1 to 10. You have to introduce 10 binary variables. Each of those binary variables indicate if the integer variable takes a particular value. For example is i is 5, z(5) should be 1 and rest of z should be 0.

therefore z1 + z2 + …+ z10 = 1 shoud be imposed.

Then you can write

i = 1*z1 + 2*z2 + … + 10*z10;

Coming to your code:

In your case, z(b,t) is the binary variable used for expanding i(t).

From the above logic, you have to know that the set b has to be 0 to 100. In your code, I see that you have declared it as an alias to b. This is incorrect.

For convenience, let’s assume i goes from 1 to 100. So b is 1 to 100. I ignore that some of your i go only to 5 or 6. You can of course implement it more elegantly but that’s not the point of this question.

```
set b/1*100/;
i(t) =e= sum(b, b.val * z(b,t));
```

You also have to ensure that only one of the z can be 1 (because I can’t take multiple values)

```
sum(b, z(b,t)) [b]=e=[/b] 1;
```

Note that in your code you set it to be **=l=** 1 which is wrong.

I have not checked my syntax so my code fragments are just guidelines.