We can create as many as we need and reuse different data sets, leaving original models and data intact. Now, right-click on Prob1ExcelRC and select Run This. Name this run configuration Prob1ExcelRC. Right-click on the project folder, click New and select Run Configurations.
#Install cplex in mac how to#
NBoxes from SheetRead(my_sheet, "'Prob1Data'!B1:B1") īesides seeing how to read from Excel, we now understand the flexibility of the run configurations. nBoxes from SheetRead(my_sheet, "'Prob1Data'!B1:B1") ĬapacityTruckX from SheetRead(my_sheet, "'Prob1Data'!B2:B2") ĬapacityTruckY from SheetRead(my_sheet, "'Prob1Data'!B3:B3") ĬostTruckX from SheetRead(my_sheet, "'Prob1Data'!B4:B4") ĬostTruckY from SheetRead(my_sheet, "'Prob1Data'!B5:B5") Within the parentheses, we define which Excel file to read with the variable sheet in this case, and then in double quotes, define the worksheet name (which is in single quotes if it has spaces) and the cell range.
We do this with the from SheetRead() command. Once we have connected to the sheet, we then can define where we get the values for our variables. The SheetConnection command is followed by a local variable name, my_sheet in this case and then the name of the Excel file in quotes. To read from Excel, we first need the SheetConnection command that connects to the spreadsheet. Right-click the project folder and select New, then Data. dat file, make sure it is in our project directory. Right-click the project folder and select Refresh (F5). We need to move the spreadsheet into the same directory as the model. We renamed the spreadsheet as Prob1.xlsx and renamed the main tab as Prob1Data.
We need to copy the values of nBoxes, capacityTruckX, ... etc. MinimumCapacityforBoxes: // name of the constraintĬapacityTruckX * truckX + capacityTruckY * truckY >= nBoxes Minimize costTruckX * truckX + costTruckY * truckY Details at the end of this post.įrom CPLEX Studio, Engine & OPL Kickstart for Optimization article, we had separated the data from model into a.
#Install cplex in mac windows#
This only works in Windows (not MacOS or Linux). Instead of recreating the data that was in an external data source – such as an Excel spreadsheet or an Access database, in this tutorial, we can load data from Excel directly.