1

I'm a total beginner with CPLEX and OPL, so maybe you can help me with the coding of a mixed integer programming model.

In my case: I have an optimization function including a parameter transportation cost which are specific for the starting point (Hubs h), the destination (DCs i), the transported good (Products k) and the mode of transportation (TransportOptions r) used.

I wrote it like this:

float transportC_Hub_DC[Hubs][DCs][Products][TransportOptions] = ...; 

//transport cost of one unit of gook k vor starting point h to destination i using transportation option r

I would like to fill this array with its multiple dimensions from an excel spread sheet. At the moment my spreadsheet has the four indexes in separate columns and the specifice transportation cost in another column. It looks like this:

Excel Datasheet

My problem is that I do not know how to make the programme understand how the transportation cost data are ordered. How does the programme know that in the first cell of the column "transportation cost" is the cost for the specific combination of the different indexes? So how do I tell the programme that I used h=1, i=1, k=1, r=1 in the first cell and h=1, i=1, k=1, r=2 in the second cell and not h=1, i=1, k=2, r=1 in the second cell? What do I have to write in the model or the data file in CPLEX to make this clear?

halfer
  • 19,824
  • 17
  • 99
  • 186
tabacoben
  • 41
  • 2

1 Answers1

1

See technote http://www-01.ibm.com/support/docview.wss?rs=0&context=SSCMS55&uid=swg21401340&loc=en_US&cs=utf-8&cc=us&lang=all

The idea is to read a tuple set and then turn your tuple set into a 4D array.

halfer
  • 19,824
  • 17
  • 99
  • 186
Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15
  • Hi Alex, thank you so much for your help. I found another thread in the IBM forum with a very similar question, so I tried to write the code like they did. I still do not know if I understood what you mean by "then turn your tuple into a 4D array". Do I write it like this? tuple HIcost { string h; string i; string k; string r; float transportC_Hub_DC; } {HIcost} HIcostData=...; float transportC_Hub_DC[Hubs][DCs][reliefgoods][transportoptions]; execute { for(var x in HIcostData) transportC_Hub_DC[x.hubs][x.DCs][x.reliefgoods][x.transportoptions]=x.transportC_Hub_DC; } – tabacoben Feb 25 '19 at 09:12