Q:

AMPL Variable Definition

I would like to define a variable in AMPL that can either be 0 or a range of values from 40 to 100.
Using var x >=40, <=100 || == 0; is not valid syntax unfortunately. Should I define one of these constraints as a parameter?

A:

This is called a semicontinuous variable and it can be defined as follows in AMPL:
var x in {0} union interval[40, 100];

