The problem statement not only specifies the components of a problem,
it also sets the context for all subsequent AMPL statements (until the
next problem statement). So in the case of
> problem A: x, objective1, c1, c2;
> problem B: y, objective2, c3, c4;
> ...
> option relax_integrality 1;
> solve A;
the option statement applied to problem B but not to problem A. If
you were to execute
solve B;
after the sequence above, you would find that B had been relaxed to an
LP.
>
> It doesnot work. (I did this because I thought all declared problems
> (A and B) are relaxed after "option relax_integrality 1;" statement.)
No, only the "current" problem (B above) is relaxed.
>
> When I put it directly after "problem A: x, objective1, c1, c2;" as
> problem A: x, objective1, c1, c2;
> option relax_integrality 1;
> problem B: y, objective2, c3, c4;
> ....
> solve A;
>
> It works.
This will relax integrality in A, but not in B.
>
> So my question is what is the effect range for "option
> relax_integrality"? In the second case, which it works, problem B is
> also relaxed or problem B stay as 0-1 model?
B should still be 0-1.
> And after I solve the
> relaxed problem for A, can A return to 0-1 model to be solved again?
Yes. Just execute
option relax_integrality 0;
while A is the current model.
Note that, once you've defined the models, you can switch context back
and forth with the problem statement. So, for instance,
problem A: x, objective1, c1, c2; # context is now A
option relax_integrality 1; # A will be relaxed
problem B: y, objective2, c3, c4; # context is now B
solve; # same as solve B; -- solves the "current" problem
solve A; # also makes A the current problem
solve B; # B is once again current
problem A; # context is again A
option relax_integrality 0; # restores integrality conditions to A
solve; # same as solve A;
/Paul