Re: [AMPL 24662] Declaring variables in diferent ways leads to diferent results

These formulations do appear to be the same, except that in the constraint you should say “if m in {10,11,12,1,2,3,4}”. But I think you could express the model even more clearly like this:

set MESES;
set MESES_A_SJ_P within MESES;

var AREA_SOJA {MESES};
var A_SJ_P >= 0;

s.t. SOJA_PLANTADA {m in MESES}:
   AREA_SOJA[m] = if m in MESES_A_SJ_P then A_SJ_P else 0;

Then in a data file for this model, you could specify the members of the two sets with the following statements:

set MESES := OUT NOV DEZ JAN FEV MAR ABR MAI JUN JUL AGO SET ;
set MESES_A_SJ_P := OUT NOV DEZ JAN FEV MAR ABR ;

I am not sure why you need to have the set JANEIRO. Is there some other constraint in the model where you need the months to be given by numbers?