Originally posted by: SystemAdmin
To Whom it May Concern,
I am new to Cplex and would like to take advantage of the excel spreadsheet data import feature. I have entered the commands I found on the tutorial, but still get errors.
I may be incorrect in trying to take a normal .dat structure and use the from syntax to pull from my spreadsheet. It seemed intuitive to me.
Specifically, the error I'm getting is that OPL claims it cannot find the excel file. I should also note that I have excel installed on my computer and use it quite frequently. I believe I have an xlsx file, but have tried this in both xlsx and xls form to no avail.
I have pasted my code below. Thanks in advance.
Model:
{string} Products = ...;
{string} Constraints = ...;
float ConsMatrix
ProductsConstraints = ...;
float Profit
Products = ...;
float Supply
Constraints = ...;
dvar float+ Production
Products;
maximize
sum(p in Products)
Profit[p] * Production[p];
subject to{
forall( c in Constraints)
ct:
sum(p in Products)
ConsMatrix[p][c] * Production[p] <= Supply[c];
}
Data:
SheetConnection sheet("OPLTrial.xls");
Products = {"newspapers" "magazines"};
Constraints = {"money" "time" "bolts"};
ConsMatrix from SheetRead(sheet,"Sheet1!A1:B3");
Profit from SheetRead(sheet,"Sheet1!E2:E4");
Supply from SheetRead(sheet,"Sheet1!H2:H3");
#DecisionOptimization#OPLusingCPLEXOptimizer