In LINGO, you can use the `@IF` function to implement conditional statements. Here's an example of how you can implement the condition you described:
```
SETS:
S /1..4/: FCst;
T /1..5/: vfc_st;
DATA:
FCst(S) = 10 15 25 30;
VARIABLES:
vfc_st(S,T) = BINARY;
! Define the condition using the @IF function
vfc_st(S,T) = @IF(FCst(S) > 20, 1, 0);
```
This code defines two sets, `S` and `T`, representing suppliers and time periods respectively. It also defines a parameter `FCst` representing the fixed ordering cost from supplier `s` in time period `t`, and a binary variable `vfc_st`. The condition is implemented using the `@IF` function, which takes three arguments: a logical expression, the value to return if the expression is true, and the value to return if the expression is false. In this case, the logical expression is `FCst(S) > 20`, and the values to return are `1` and `0`.
Lyudmil Antonov But FCst is two dimension parameter and related to T and S but you define one dimension. and i think in Defining the condition using the @IF function we should also use @for, right?
Yes, you are correct. The `FCst` parameter should be two-dimensional to represent the fixed ordering cost from supplier `s` in time period `t`. You can define it like this:
``` SETS: S /1..4/: FCst; T /1..5/: vfc_st; DATA: FCst(S,T) = 10 15 25 30; VARIABLES: vfc_st(S,T) = BINARY; ! Define the condition using the @IF function vfc_st(S,T) = @IF(FCst(S,T) > 20, 1, 0); ``` You can also use the `@FOR` function to iterate over the elements of a set and apply the condition to each element. Here's an example: ``` SETS: S /1..4/: FCst; T /1..5/: vfc_st; DATA: FCst(S,T) = 10 15 25 30; VARIABLES: vfc_st(S,T) = BINARY; ! Define the condition using the @IF and @FOR functions @FOR(S(s), @FOR(T(t), vfc_st(s,t) = @IF(FCst(s,t) > 20, 1, 0))); ``` This code uses nested `@FOR` functions to iterate over the elements of sets `S` and `T`, and applies the condition to each element using the `@IF` function. Is this what you were looking for?
Lyudmil Antonov i have the other big model that has this binary variable and also should if condition for this binary variable but when i solve the model decision variable take zero value and when i check i see the binary variable didn't work, now i want to know how to write if condition in my model
but sorry your defined code is not work in lingo with '@for', is it possible to write me in exactly with lingo function. i don't know where is the problem
It’s possible that there is an issue with the logic of your code. From what you’ve shared, it seems like you’re trying to create a two-dimensional array vfc with dimensions sup and per, and then assign values to it based on the values in the FC array. However, it’s difficult to tell what the issue is without more information about the context and purpose of your code. For example, if all results are zero (vfc_st = 0) then all FCst are less or equal to 20 and there may be a reason for this.
Can you provide more details about what you’re trying to achieve with this code and what the expected result should be?