0

I wanna convert this if statement to linear equation.

for i,j -> 1 to n 
if D[i]>D[j] and f[i] > s[j] then w[i]+=c[j]

The line below is what has come to my mind so far, but I do not know how to write the rest. C(j) has to be multiplied by a phrase (that phrase is a code condition) If the result of that phrase (in parentheses below) was 1, add C(j) to w(j) and if it was 0, do not add it to w(j). Can you tell me how to write that condition in such a way that if the condition is true, it becomes 1, and if the condition is false, it become 0?

sum( j, c[j]*(?) )
parham
  • 1
  • 1

1 Answers1

0

What do you refer for "to be multiplied by a phrase"? Phrase is a parameter or a variable in the model? C(j) is data or is a variable? Depending on your answer, you should add binary variables to your model to register the result of that phrase and then you have to formulate the conditional sum of c(j) and w(j) depending on that binary variable.