You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-5Lines changed: 19 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,18 +6,21 @@ OPL custom data source API to import data from a JDBC data source into an OPL mo
6
6
This sample illustrates the [Subclassing IloCustomOplDataSoource](https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.8.0/ilog.odms.ide.help/OPL_Studio/opllanguser/topics/opl_languser_extfunc_datasubcl.html) section from the OPL User's manual.
7
7
This sample shows how to read and write tuplesets to/from a database with Java. It also enables you to read a database and generate .dat files to be used in the IDE to prototype your optimization model.
8
8
9
-
While this sample uses MySQL as data storage, it can be easily adapted to
10
-
any database that has JDBC drivers.
9
+
One [variation](examples/ilo_opl_call_java) of this sample shows how to read and write tuplesets to/from a database involving only some scripting in your .dat
10
+
11
+
This sample comes with example connection configurations to DB2, MySQL and MS SQL Server. It can
12
+
be easily adapted to any database that has JDBC drivers.
11
13
This example will work with any 12.x OPL version, even if it is configured to run with 12.8.0 version.
12
14
13
15
14
16
## Table of Contents
15
17
-[Prerequisites](#prerequisites)
16
-
-[Build and run the sample](#build-and-run-the-sample)
18
+
-[Build and run the sample from java](#build-and-run-the-sample-from-java)
17
19
-[Build the sample](#build-the-sample)
18
20
-[Run sample with DB2](#run-sample-with-db2)
19
21
-[Run sample with MySQL](#run-sample-with-mysql)
20
-
-[Run sample with MS SQL Server](#run-sample-with-ms-sql-server)
22
+
-[Run sample with MS SQL Server](#run-sample-with-ms-sql-server)
23
+
-[Run the sample from OPL](#run-the-sample-from-opl)
21
24
-[Export plain dat files](#export-plain-dat-files)
22
25
-[Run with a previous OPL version](#run-with-a-previous-opl-version)
23
26
-[License](#license)
@@ -41,7 +44,10 @@ This example will work with any 12.x OPL version, even if it is configured to ru
41
44
MySQL Comunity Server, but is compatible with minimal changes with other JDBC
42
45
compatible databases.
43
46
44
-
## Build and run the sample
47
+
## Build and run the sample from java
48
+
49
+
The default sample uses model and data from [examples/oil](examples/oil)
50
+
45
51
### Build the sample
46
52
47
53
Before you build the sample, you must edit `build.properties` for the appropriate path locations:
@@ -203,6 +209,14 @@ $ ant run_mssql
203
209
204
210
205
211
212
+
### Run the sample from OPL
213
+
214
+
Sample in [examples/ilo_opl_call_java](examples/ilo_opl_call_java) shows how to
215
+
use the jdbc custom data source as a library, without having the need to
216
+
invoke OPL runtime from java. You can use this method to access database
217
+
using a jdbc-custom-data-source from `oplrun` or OPL Studio.
218
+
219
+
206
220
### Reusing the sample with other databases
207
221
As the sample is build on JDBC, it's possible to reuse <code>JdbcCustomDataSource</code> with minimal changes:
* An oil company manufactures different types of gasoline and diesel. Each type of gasoline is produced by blending different types of crude oils that must be purchased. The company must decide how much crude oil to buy in order to maximize its profit while respecting processing capacities and quality levels as well as satisfying customer demand.
6
+
* Blending problems are a typical industry application of Linear Programming (LP). LP represents real life problems mathematically using an objective function to represent the goal that is to be minimized or maximized, together with a set of linear constraints which define the conditions to be satisfied and the limitations of the real life problem. The function and constraints are expressed in terms of decision variables and the solution, obtained from optimization engines such as IBM® ILOG® CPLEX®, provides the best values for these variables so that the objective function is optimized.
7
+
* The oil-blending problem consists of calculating different blends of gasoline according to specific quality criteria.
8
+
* Three types of gasoline are manufactured: super, regular, and diesel.
9
+
* Each type of gasoline is produced by blending three types of crude oil: crude1, crude2, and crude3.
10
+
* The gasoline must satisfy some quality criteria with respect to their lead content and their octane ratings, thus constraining the possible blendings.
11
+
* The company must also satisfy its customer demand, which is 3,000 barrels a day of super, 2,000 of regular, and 1,000 of diesel.
12
+
* The company can purchase 5,000 barrels of each type of crude oil per day and can process at most 14,000 barrels a day.
13
+
* In addition, the company has the option of advertising a gasoline, in which case the demand for this type of gasoline increases by ten barrels for every dollar spent.
14
+
* Finally, it costs four dollars to transform a barrel of oil into a barrel of gasoline.
15
+
16
+
## Files
17
+
18
+
`oil.mod` contains the OPL Model.
19
+
20
+
`oil.dat` contains part of the input data. Mostly parameters for the problem, like max production and production cost. The missing input data sets (OilData and GasData are read from the database at run time using the sql queries defined in the database connection xml configuration file)
0 commit comments