![]() Use a 3rd party library (like that Apache POI framework) to load Excel data into our model.Refer How to import data from csv file by Alex Fleischer. csv file and use an IloOplInputFile to load/parse this file. Unfortunately, reading data from Excel is not supported on MacOS and Linux. If we tried to read data from Excel to CPLEX in Macbook, the error “Sheet data not supported on this platform” will be shown. 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. 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. In this video, we look at how we can quickly get started with creating an optimization model in the Optimization Programming Language (OPL) and Python. 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. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |