I am new to GAMS and the documentation is not helping me to make fast progress. I am looking for an example implementation similar to Relax and Fix heuristic where in several iterations subsets of binary variables are relaxed/fixed.


1 Answer 1


To fix a variable use x.fx(i) = 1. To unfix: x.lo(i) = 0; x.up(i) = 1;.

To relax an integer/binary variable you can use: x.prior(i)=INF;

Documentation of this can be found at the obvious place: https://www.gams.com/latest/docs/UG_Variables.html. Here is an example of how to use this.

  • $\begingroup$ ty for the helpful comment. I saw u already hardcoded the subsets for the iterations, but i would prefer to do do this with a rolling-parameter and planning horizon width automatically. Any good advise there? I guess i have to read the whole documentation.. $\endgroup$
    – Eddiee
    Nov 10, 2020 at 11:14
  • $\begingroup$ Sets can be dynamic. See the documentation. $\endgroup$ Nov 10, 2020 at 11:23
  • $\begingroup$ i have my set of time.. ##code## Set t "Menge der Zeitperioden" /T1 * T20/ ##code## i an trying to get a subset lets say from T5 to T10. How is this done? MY research: t_f(t) = yes$(ord(t) le 4) ; ok it worked $\endgroup$
    – Eddiee
    Nov 10, 2020 at 11:43
  • $\begingroup$ Whats the difference when applying prior or lo and up to a binary? $\endgroup$
    – Eddiee
    Nov 10, 2020 at 12:55
  • $\begingroup$ Relaxing for x.prior(i) means: the variable is no longer binary but continuous. To relax bounds, use x.lo(i) and x.up(i). $\endgroup$ Nov 10, 2020 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.