AnsweredAssumed Answered

Reading a string as a decision-variable name

Question asked by pmlwd@leeds.ac.uk on Sep 12, 2015
Latest reply on Oct 20, 2015 by pmlwd@leeds.ac.uk

Hello there

 

Is it possible to convert strings for use in functions such as getsol()? I think that what I am looking for would be something comparable to INDIRECT() in Excel. I've read through the documentation on the procedures and functions for mmsystem, but I can't find anything that seems suitable. I attach a very simple demonstration of what I am trying to do, which when run produces the following error: "error 102: Incompatible types for parameters of `getsol'."


Any help on this would be greatly appreciated.

 

Thanks

 

----------------------------------------------------------------------

model Demo

uses "mmxprs"

 

  declarations

  PRINTLIST={"a","b"}

  NUM=3

  a:array(1..NUM) of mpvar

  b:array(1..NUM) of mpvar

  end-declarations

 

  minimise(sum(i in 1..NUM)(a(i)+b(i)))     ! This is simply to engage the solver

 

  forall(i in 1..getsize(PRINTLIST)) do

  forall(j in 1..NUM) do

  writeln(getsol(PRINTLIST(i)+"("+j+")"))

  end-do

  end-do

 

end-model

Outcomes