'GAMS: Linear constraints for logical conditions

How can we write the following if else statements containing decision variable as linear constraints in GAMS?

Here x is a the decision variable.

if (((x>=0) and (x<=0.5)), y= a1;
else if((x>=0.5) and (x<=1)), y=a2;
else if((x>=1) and (x<=1.5)), y=a3;
else y=a4;
);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source