Hello,

I have the following problem/question:

I have a decision variable (an array), let`s call it y and a seperate array "f".

How would I go about linking them? I.e. any position in f smaller than a given value "R" would increase the same position in y to "1"?

Thank you for the help.

Assuming you wish to state the relation: 'if f(i)<=R then x(i)>=1' where x(i) is a decision variable, there are several cases:

1. f is an array of numerical type (integer, real): this states a bound on variables x(i)

declarations

x: array(S) of mpvar

f: array(S) of real

end-declarations

forall(i in S | f(i)<=R) x(i)>=1

2. Both arrays are of type mpvar (or f is of type linctr) and x(i) are binary variables: the implication can be transformed into its inverse which is the indicator constraint 'if x(i)=0 then f(i)>=R+m' where m is some small value, slightly larger than the feasibility tolerance

declarations

x: array(S) of mpvar

f: array(S) of mpvar

end-declarations

m:=5*getparam("XPRS_FEASTOL")

forall(i in S) x(i) is_binary

forall(i in S) indicator(-1,x(i), f(i)>=R+m)

3. Same as 2 but x(i) are not binaries: an option that is easy from a modelling point of view is to use a formulation via logic constraints (provided by the package 'advmod' that needs to be loaded by your model)

declarations

x: array(S) of mpvar

f: array(S) of mpvar

end-declarations

forall(i in S) implies(f(i)<=R, x(i)>=1)

On the topic of indicator and logic constraints, take a look at this document: Redirecting...