Topic
  • 1 reply
  • Latest Post - ‏2013-07-04T09:39:05Z by VincentBeraudier
waterstyler
waterstyler
2 Posts

Pinned topic assigning fix values to my variable

‏2013-06-11T16:02:18Z |

Hello

I have this variable-constraint

Iit = sum (k in Facility)(Fkit+ Lkit) for all i,t

If I code this as a constraint I think I am going to get error due to not having value for I(it) as a result I was thinking of coding it as variable after my objective function. 

dvar int I[i in Facility][t in Time] = sum(k in Facility)(F[k][i][t] + L[k][i][t]);

error:can not use dexpe int after dvar int

In AMPL I can use variable instead of constraint by just saying "var I{i in Facility,t in Time} =  sum{k in Facility}(F[k,i,t] + L[k,i,t]);"

Thanks alot
Updated on 2013-06-11T16:02:28Z at 2013-06-11T16:02:28Z by waterstyler
  • VincentBeraudier
    VincentBeraudier
    13 Posts

    Re: assigning fix values to my variable

    ‏2013-07-04T09:39:05Z  

    you have to either declare a variable array and do the == condition in the constrints block such as:

    <code>

    dvat int I[i in Facility][t in Time];

    subject to{

    forall(i in Facility, t in Time) I[i][j] == sum(k in Facility)(F[k][i][t] + L[k][i][t]);;

    }

    </code>

    or you can declare a decision expression with :

    <code>

    dexpr int I[i in Facility][t in Time] = sum(k in Facility)(F[k][i][t] + L[k][i][t]);

    </code> then use I in constraints block.