Hi,
you need to use tuple set.
For instance if you have .mod
{string} myData = ...;
{string} myDataSet [myData ] = ...;
and .dat
myData={"A","B"};
myDataSet=[{"C","D"},{}];
which run fine with CPLEX on your machine.
You need to turn that into .mod
{string} myData = ...;
tuple t
{
string s1;
string s2;
}
{t} myDataSet with s1 in myData=...;
{string} myDataSet2[i in myData]={j.s2 | j in myDataSet : j.s1==i};
execute
{
writeln(myDataSet2);
}
and .dat
myData={"A","B"};
myDataSet={<"A","C">,<"A","D">};
which run fine on your machine too but will also work in Watson Studio if you turn your .dat into a csv file
regards
------------------------------
ALEX FLEISCHER
------------------------------
Original Message:
Sent: Fri June 05, 2020 10:51 AM
From: Margarit Khachatryan
Subject: OPL examples in Watson Studio
Alex,
Thanks, in my original message that is what I did but could't figure out how to read the
myDataSet = [
,{"el1_Item1", "el2_Item1"}
,{"el1_Item2"}
,{"el1_Item3", "el2_Item3", "el3_Item3"}
]
The usual way to read is
{string} myDataSet [myData ] = ...;
Basically,
myDataSet ["Item1"] should return {"el1_Item1", "el2_Item1"}
------------------------------
Margarit Khachatryan
Original Message:
Sent: Fri June 05, 2020 10:37 AM
From: ALEX FLEISCHER
Subject: OPL examples in Watson Studio
Hi,
could you try to use tuple sets instead of sets ?
Instead of
{string} myData = ...;try
tuple t{ string st;}{t} myData = ...;regards
------------------------------
ALEX FLEISCHER
Original Message:
Sent: Fri June 05, 2020 10:26 AM
From: Margarit Khachatryan
Subject: OPL examples in Watson Studio
Zoo example run fine for me. Note how in this example the parameters are read - again through tuples.
{bus} buses=...;
Can you share how to read these data
myData = {"Item 1", "Item2", "Item3"}
myDataSet = [
,{"el1_Item1", "el2_Item1"}
,{"el1_Item2"}
,{"el1_Item3", "el2_Item3", "el3_Item3"}
]
The regular lines below do not work
{string} myData = ...;
{string} myDataSet [myData ] = ...;
Thanks
------------------------------
Margarit Khachatryan
Original Message:
Sent: Fri June 05, 2020 09:50 AM
From: ALEX FLEISCHER
Subject: OPL examples in Watson Studio
Hi,
OPL works fine in Watson Studio.
Let me again share the zoo example.
Take zoo.csv
40;50030;400
import zoo.csv in Watson Studio
and name the columns in order to see
and then you ll be able to run and see the result
------------------------------
ALEX FLEISCHER
Original Message:
Sent: Fri June 05, 2020 02:29 AM
From: Margarit Khachatryan
Subject: OPL examples in Watson Studio
Hi All,
Are there examples of OPL models in Watson Studio? It seems OPL models are not possible to directly migrate to Watson Studio. Seems reading data not always same
Just to read data
myData = {"Item 1", "Item2", "Item3"}
myDataSet = [
,{"el1_Item1", "el2_Item1"}
,{"el1_Item2"}
,{"el1_Item3", "el2_Item3", "el3_Item3"}
]
For example simple file read line
{string} myData = ...;
generated an error
Element 'myData ' provided in CSV data source cannot be mapped to OPL type: 'SET' as this type is not supported for input data on the Cloud.
I had to rewrite into to have it worked
tuple myString{
key string myData ;
}
{myString} myData = ...;
The question is how do I read myDataSet . In OPL I would read in the following way
{string} myDataSet [myData ] = ...;
Thanks
------------------------------
Maga
------------------------------
#DecisionOptimization