Skip to content

Commit 19f1f74

Browse files
authored
Merge pull request #2392 from oracle-devrel/operational-research
initial commit for operational research demos
2 parents 05c8120 + b2695fe commit 19f1f74

File tree

7 files changed

+2600
-0
lines changed

7 files changed

+2600
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2026 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Overview
2+
3+
This project presents three operational research use cases with different levels of complexity:
4+
5+
1. **Finding the best route using Dijkstra’s algorithm** – the simplest use case.
6+
2. **Flight scheduling using integer linear programming.**
7+
3. **Individual pricing optimization with global and individual constraints** – an advanced use case that also showcases the use of different resources and features in the OCI Data Science Platform.
8+
9+
Reviewed: 2026.01.05
10+
11+
# What You’ll Learn
12+
13+
This project covers the following topics:
14+
15+
1. Background on optimization tools used in operational research, including linear programming, the Brent method, and root-finding techniques for computing Lagrange multipliers.
16+
2. Background on the different use cases, with a focus on the individual pricing optimization use case.
17+
3. OCI Data Science Platform components used in this project, including:
18+
- Notebook Sessions
19+
- Model serialization
20+
- Model Catalog
21+
- Model deployment
22+
- Endpoint invocation for predictions
23+
- Data Science Jobs
24+
25+
# Prerequisites
26+
27+
- Access to the OCI Data Science Platform
28+
- Basic familiarity with Python and machine learning concepts
29+
- A valid OCI compartment, resource principal, and policies configured for Data Science services
30+
31+
# How to Use this asset?
32+
33+
1. Open the provided notebook in your OCI Data Science Notebook Session.
34+
2. Select the following conda environment: generalml_p311_cpu_x86_64_v1
35+
3. Run the notebook cells in sequence to reproduce the complete workflow.
36+
37+
# License
38+
39+
Copyright (c) 2026 Oracle and/or its affiliates.
40+
41+
Licensed under the Universal Permissive License (UPL), Version 1.0.
42+
43+
See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE) for more details.

data-platform/data-science/oracle-data-science/operational-research/files/dijkstra's_algorithm.ipynb

Lines changed: 376 additions & 0 deletions
Large diffs are not rendered by default.

data-platform/data-science/oracle-data-science/operational-research/files/flight_planning.ipynb

Lines changed: 199 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "33545924-d88b-4b8b-9a71-a0f229b58759",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import numpy as np\n",
11+
"import pandas as pd"
12+
]
13+
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": 3,
17+
"id": "c76dba70-77fb-4ea8-a82f-ef7f44b23400",
18+
"metadata": {},
19+
"outputs": [],
20+
"source": [
21+
"def simulate_training_data(size):\n",
22+
" age = np.random.uniform(20, 70, size)\n",
23+
" risk = np.random.uniform(0, 1, size)\n",
24+
" price = np.random.uniform(2, 4,size)\n",
25+
"\n",
26+
" beta_0 = 3.0\n",
27+
" beta_price = -1.5\n",
28+
" beta_age = 0.05\n",
29+
" beta_risk = -1.0\n",
30+
" \n",
31+
" logit = (\n",
32+
" beta_0\n",
33+
" + beta_price * price\n",
34+
" + beta_age * age\n",
35+
" + beta_risk * risk\n",
36+
" )\n",
37+
"\n",
38+
" prob = 1 / (1 + np.exp(-logit))\n",
39+
" purchase = np.random.binomial(1, prob)\n",
40+
"\n",
41+
"\n",
42+
" df = pd.DataFrame({\n",
43+
" \"price\": price,\n",
44+
" \"age\": age,\n",
45+
" \"risk\": risk,\n",
46+
" \"purchase\": purchase\n",
47+
" })\n",
48+
" return df"
49+
]
50+
},
51+
{
52+
"cell_type": "code",
53+
"execution_count": null,
54+
"id": "5da7f09a-04ad-4ac6-b648-2109bf476285",
55+
"metadata": {},
56+
"outputs": [],
57+
"source": [
58+
"df=new_customer_data=simulate_training_data(200)"
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": 4,
64+
"id": "036a12b9-256f-46ca-8909-f886f95349b2",
65+
"metadata": {},
66+
"outputs": [],
67+
"source": [
68+
"df.to_csv(\"./data/price_opt_data_1000.csv\", index=False)"
69+
]
70+
},
71+
{
72+
"cell_type": "code",
73+
"execution_count": 2,
74+
"id": "806cb91d-d16d-44fb-80f0-b77c647ff0a3",
75+
"metadata": {},
76+
"outputs": [],
77+
"source": [
78+
"def simulate_new_cases(size):\n",
79+
" age = np.random.uniform(20, 70, size)\n",
80+
" risk = np.random.uniform(0, 1, size)\n",
81+
"\n",
82+
" df = pd.DataFrame({\n",
83+
" \"age\": age,\n",
84+
" \"risk\": risk,\n",
85+
" })\n",
86+
" return df"
87+
]
88+
},
89+
{
90+
"cell_type": "code",
91+
"execution_count": 6,
92+
"id": "4fdf26b0-edc0-404d-a3cb-027eeb615d19",
93+
"metadata": {},
94+
"outputs": [],
95+
"source": [
96+
"new_customer_data=simulate_new_cases(50)"
97+
]
98+
},
99+
{
100+
"cell_type": "code",
101+
"execution_count": 7,
102+
"id": "5b2851e2-87cc-4e5f-9a79-76d73e31051f",
103+
"metadata": {},
104+
"outputs": [],
105+
"source": [
106+
"new_customer_data.to_csv(\"./data/new_customers_50.csv\")"
107+
]
108+
},
109+
{
110+
"cell_type": "code",
111+
"execution_count": 8,
112+
"id": "0a0579ff-02a4-40c4-b1e3-649eeb39da3e",
113+
"metadata": {},
114+
"outputs": [
115+
{
116+
"data": {
117+
"text/plain": [
118+
"<oci.response.Response at 0x7f4665b62d50>"
119+
]
120+
},
121+
"execution_count": 8,
122+
"metadata": {},
123+
"output_type": "execute_result"
124+
}
125+
],
126+
"source": [
127+
"import oci\n",
128+
"from oci.object_storage import UploadManager\n",
129+
"\n",
130+
"signer = oci.auth.signers.get_resource_principals_signer()\n",
131+
"object_storage = oci.object_storage.ObjectStorageClient({}, signer=signer)\n",
132+
"namespace = object_storage.get_namespace().data\n",
133+
"\n",
134+
"bucket_name = \"filesdemo\"\n",
135+
"file_name = \"operational_research/new_cases.csv\"\n",
136+
"\n",
137+
"local_path='./data/new_customers_50.csv'\n",
138+
"\n",
139+
"upload_manager = UploadManager(object_storage, allow_parallel_uploads=True)\n",
140+
"upload_manager.upload_file(\n",
141+
" namespace_name=namespace,\n",
142+
" bucket_name=bucket_name,\n",
143+
" object_name=file_name,\n",
144+
" file_path=local_path\n",
145+
")"
146+
]
147+
},
148+
{
149+
"cell_type": "code",
150+
"execution_count": null,
151+
"id": "923a05a3-88b3-4568-b7c2-508160b08189",
152+
"metadata": {},
153+
"outputs": [],
154+
"source": []
155+
}
156+
],
157+
"metadata": {
158+
"kernelspec": {
159+
"display_name": "Python [conda env:generalml_p311_cpu_x86_64_v1]",
160+
"language": "python",
161+
"name": "conda-env-generalml_p311_cpu_x86_64_v1-py"
162+
},
163+
"language_info": {
164+
"codemirror_mode": {
165+
"name": "ipython",
166+
"version": 3
167+
},
168+
"file_extension": ".py",
169+
"mimetype": "text/x-python",
170+
"name": "python",
171+
"nbconvert_exporter": "python",
172+
"pygments_lexer": "ipython3",
173+
"version": "3.11.9"
174+
}
175+
},
176+
"nbformat": 4,
177+
"nbformat_minor": 5
178+
}

0 commit comments

Comments
 (0)