Forum Discussion

FICO's avatar
FICO
Community Manager
6 years ago

Need help to solve E-101: Incompatible types in assignment ('array of linctr' := 'linctr')

I am trying to solve a simple routing model using Xpress, but I obtain the error message as stated above. The error appears in every constraint where I have declared the constraint as

Contraint: array (indices) of linctr

One example of a constraint is:

forall (tt in TimePeriods) do

CargoCon :=

l(tt) = l(tt-1) + sum(ii in Locations) q(ii,tt);

end-do

declarations are:

CargoCon: array(TimePeriods) of linctr

l: dynamic array(TimePeriods) of mpvar

q: dynamic array (Locations, TimePeriods) of mpvar

Both TimePeriods and Locations are sets of integer values.

Thanks

2 Replies

  • FICO's avatar
    FICO
    Community Manager

    You need to employ the index value (or index tuple) when enumerating the entries of an array of 'linctr', just like what you are doing for other types of arrays (eg array of mpvar) in your example:

    forall (tt in TimePeriods)

    CargoCon(tt) :=

    l(tt) = l(tt-1) + sum(ii in Locations) q(ii,tt); ! NB: there probably needs to be a test on the 'tt-1' index, perhaps something like: if(t>1, l(tt-1), 0)

  • FICO's avatar
    FICO
    Community Manager

    Worked like a charm! Yes, you were right. I had to implement "if (tt>=1) then " -statements on each constraint where this was the case.

    Thank you.