Skip to content

Commit 3f8d04b

Browse files
committed
2.8.125
1 parent 0fc9cf0 commit 3f8d04b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+839
-2852
lines changed

examples/cp/basic/color.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141

4242
# Solve model
4343
print("\nSolving model....")
44-
# You can set here custom DOcplexcloud URL and key if not done in docloud_config.py
45-
msol = mdl.solve(TimeLimit=10, url="ENTER YOUR URL HERE", key="ENTER YOUR KEY HERE")
44+
msol = mdl.solve(TimeLimit=10)
4645

4746
if msol:
4847
print("Solution status: " + msol.get_solve_status())

examples/cp/basic/n_queen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
if msol:
6262
stdout.write("Solution:")
6363
for v in x:
64-
stdout.write(" " + str(msol[v]))
64+
stdout.write(" {}".format(msol[v]))
6565
stdout.write("\n")
6666
# Draw chess board
6767
for l in range(NB_QUEEN):
@@ -71,4 +71,4 @@
7171
stdout.write("Q" if c == qx else ".")
7272
stdout.write("\n")
7373
else:
74-
stdout.write("Solve status: " + msol.get_solve_status() + "\n")
74+
stdout.write("Solve status: {}\n".format(msol.get_solve_status()))

examples/cp/jupyter/SteelMill.ipynb

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,21 @@
1313
"\n",
1414
">This notebook is part of the **[Prescriptive Analytics for Python](https://rawgit.com/IBMDecisionOptimization/docplex-doc/master/docs/index.html)**\n",
1515
"\n",
16-
">It requires a valid subscription to **Decision Optimization on the Cloud** or a **local installation of CPLEX Optimizers**. \n",
17-
"Discover us [here](https://developer.ibm.com/docloud)\n",
18-
"\n",
16+
">It requires a **local installation of CPLEX Optimizers**. \n",
1917
"\n",
2018
"Table of contents:\n",
2119
"\n",
2220
"- [Describe the business problem](#Describe-the-business-problem)\n",
2321
"* [How decision optimization (prescriptive analytics) can help](#How--decision-optimization-can-help)\n",
2422
"* [Use decision optimization](#Use-decision-optimization)\n",
2523
" * [Step 1: Download the library](#Step-1:-Download-the-library)\n",
26-
" * [Step 2: Set up the engines](#Step-2:-Set-up-the-prescriptive-engine)\n",
27-
" - [Step 3: Model the Data](#Step-3:-Model-the-data)\n",
28-
" * [Step 4: Prepare the data](#Step-4:-Prepare-the-data)\n",
29-
" - [Step 4: Set up the prescriptive model](#Step-4:-Set-up-the-prescriptive-model)\n",
24+
" * [Step 2: Model the Data](#Step-2:-Model-the-data)\n",
25+
" * [Step 3: Set up the prescriptive model](#Step-3:-Set-up-the-prescriptive-model)\n",
3026
" * [Define the decision variables](#Define-the-decision-variables)\n",
3127
" * [Express the business constraints](#Express-the-business-constraints)\n",
3228
" * [Express the objective](#Express-the-objective)\n",
3329
" * [Solve with Decision Optimization solve service](#Solve-with-Decision-Optimization-solve-service)\n",
34-
" * [Step 5: Investigate the solution and run an example analysis](#Step-5:-Investigate-the-solution-and-then-run-an-example-analysis)\n",
30+
" * [Step 4: Investigate the solution and run an example analysis](#Step-4:-Investigate-the-solution-and-then-run-an-example-analysis)\n",
3531
"* [Summary](#Summary)\n",
3632
"****"
3733
]
@@ -124,26 +120,7 @@
124120
"cell_type": "markdown",
125121
"metadata": {},
126122
"source": [
127-
"### Step 2: Set up the prescriptive engine\n",
128-
"\n",
129-
"* Subscribe to the [Decision Optimization on Cloud solve service](https://developer.ibm.com/docloud).\n",
130-
"* Get the service URL and your personal API key.\n",
131-
"\n",
132-
"__Set your DOcplexcloud credentials:__\n",
133-
"0. A first option is to set the DOcplexcloud url and key directly in the model source file *(see below)*\n",
134-
"1. For a persistent setting, create a Python file __docloud_config.py__ somewhere that is visible from the __PYTHONPATH__"
135-
]
136-
},
137-
{
138-
"cell_type": "code",
139-
"execution_count": null,
140-
"metadata": {
141-
"collapsed": true
142-
},
143-
"outputs": [],
144-
"source": [
145-
"SVC_URL = \"ENTER YOUR URL HERE\"\n",
146-
"SVC_KEY = \"ENTER YOUR KEY HERE\""
123+
"### Step 2: Model the data"
147124
]
148125
},
149126
{
@@ -157,13 +134,6 @@
157134
"from docplex.cp.model import *"
158135
]
159136
},
160-
{
161-
"cell_type": "markdown",
162-
"metadata": {},
163-
"source": [
164-
"### Step 3: Model the data"
165-
]
166-
},
167137
{
168138
"cell_type": "markdown",
169139
"metadata": {},
@@ -241,7 +211,7 @@
241211
"cell_type": "markdown",
242212
"metadata": {},
243213
"source": [
244-
"### Step 4: Set up the prescriptive model"
214+
"### Step 3: Set up the prescriptive model"
245215
]
246216
},
247217
{
@@ -340,7 +310,7 @@
340310
"cell_type": "markdown",
341311
"metadata": {},
342312
"source": [
343-
"#### Solve with Decision Optimization solve service"
313+
"#### Solve the model"
344314
]
345315
},
346316
{
@@ -355,14 +325,14 @@
355325
"# Search strategy\n",
356326
"mdl.set_search_phases([search_phase([production_slab[o] for o in orders])])\n",
357327
"\n",
358-
"msol = mdl.solve(url=SVC_URL, key=SVC_KEY, FailLimit=100000, TimeLimit=10)"
328+
"msol = mdl.solve(FailLimit=100000, TimeLimit=10)"
359329
]
360330
},
361331
{
362332
"cell_type": "markdown",
363333
"metadata": {},
364334
"source": [
365-
"### Step 5: Investigate the solution and then run an example analysis"
335+
"### Step 4: Investigate the solution and then run an example analysis"
366336
]
367337
},
368338
{
@@ -394,7 +364,7 @@
394364
"source": [
395365
"## Summary\n",
396366
"\n",
397-
"You learned how to set up and use the IBM Decision Optimization CPLEX Modeling for Python to formulate a Constraint Programming model and solve it with IBM Decision Optimization on the cloud."
367+
"You learned how to set up and use the IBM Decision Optimization CPLEX Modeling for Python to formulate and solve a Constraint Programming model."
398368
]
399369
},
400370
{
@@ -412,27 +382,27 @@
412382
"cell_type": "markdown",
413383
"metadata": {},
414384
"source": [
415-
"Copyright © 2017 IBM. IPLA licensed Sample Materials."
385+
"Copyright © 2017, 2018 IBM. IPLA licensed Sample Materials."
416386
]
417387
}
418388
],
419389
"metadata": {
420390
"kernelspec": {
421-
"display_name": "Python [conda root]",
391+
"display_name": "Python 2",
422392
"language": "python",
423-
"name": "conda-root-py"
393+
"name": "python2"
424394
},
425395
"language_info": {
426396
"codemirror_mode": {
427397
"name": "ipython",
428-
"version": 3
398+
"version": 2
429399
},
430400
"file_extension": ".py",
431401
"mimetype": "text/x-python",
432402
"name": "python",
433403
"nbconvert_exporter": "python",
434-
"pygments_lexer": "ipython3",
435-
"version": "3.5.2"
404+
"pygments_lexer": "ipython2",
405+
"version": "2.7.11"
436406
}
437407
},
438408
"nbformat": 4,

examples/cp/jupyter/golomb_ruler.ipynb

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,27 @@
88
"\n",
99
"This tutorial includes everything you need to set up decision optimization engines, build constraint programming models.\n",
1010
"\n",
11-
"\n",
1211
"When you finish this tutorial, you'll have a foundational knowledge of _Prescriptive Analytics_.\n",
1312
"\n",
1413
">This notebook is part of the **[Prescriptive Analytics for Python](https://rawgit.com/IBMDecisionOptimization/docplex-doc/master/docs/index.html)**\n",
1514
"\n",
16-
">It requires a valid subscription to **Decision Optimization on the Cloud** or a **local installation of CPLEX Optimizers**. \n",
15+
">It requires a **local installation of CPLEX Optimizers**. \n",
1716
"\n",
1817
"Discover us [here](https://developer.ibm.com/docloud)\n",
1918
"\n",
20-
"\n",
2119
"Table of contents:\n",
2220
"\n",
2321
"- [Describe the business problem](#Describe-the-business-problem)\n",
2422
"* [How decision optimization (prescriptive analytics) can help](#How--decision-optimization-can-help)\n",
2523
"* [Use decision optimization](#Use-decision-optimization)\n",
2624
" * [Step 1: Download the library](#Step-1:-Download-the-library)\n",
27-
" * [Step 2: Set up the engines](#Step-2:-Set-up-the-prescriptive-engine)\n",
28-
" - [Step 3: Model the Data](#Step-3:-Model-the-data)\n",
29-
" - [Step 4: Set up the prescriptive model](#Step-4:-Set-up-the-prescriptive-model)\n",
25+
" * [Step 2: Model the Data](#Step-2:-Model-the-data)\n",
26+
" * [Step 3: Set up the prescriptive model](#Step-3:-Set-up-the-prescriptive-model)\n",
3027
" * [Define the decision variables](#Define-the-decision-variables)\n",
3128
" * [Express the business constraints](#Express-the-business-constraints)\n",
3229
" * [Express the objective](#Express-the-objective)\n",
3330
" * [Solve with Decision Optimization solve service](#Solve-with-Decision-Optimization-solve-service)\n",
34-
" * [Step 5: Investigate the solution and run an example analysis](#Step-5:-Investigate-the-solution-and-then-run-an-example-analysis)\n",
31+
" * [Step 4: Investigate the solution and run an example analysis](#Step-4:-Investigate-the-solution-and-then-run-an-example-analysis)\n",
3532
"* [Summary](#Summary)\n",
3633
"****"
3734
]
@@ -143,30 +140,7 @@
143140
"cell_type": "markdown",
144141
"metadata": {},
145142
"source": [
146-
"### Step 2: Set up the prescriptive engine\n",
147-
"\n",
148-
"* Subscribe to the [Decision Optimization on Cloud solve service](https://developer.ibm.com/docloud).\n",
149-
"* Get the service URL and your personal API key."
150-
]
151-
},
152-
{
153-
"cell_type": "code",
154-
"execution_count": null,
155-
"metadata": {
156-
"collapsed": true
157-
},
158-
"outputs": [],
159-
"source": [
160-
"# Initialize IBM Decision Optimization credentials\n",
161-
"SVC_URL = \"ENTER YOUR URL HERE\"\n",
162-
"SVC_KEY = \"ENTER YOUR KEY HERE\""
163-
]
164-
},
165-
{
166-
"cell_type": "markdown",
167-
"metadata": {},
168-
"source": [
169-
"Now, we need to import all required modeling functions that are provided by the <i>docplex.cp</i> package:"
143+
"### Step 2: Model the data\n"
170144
]
171145
},
172146
{
@@ -185,7 +159,6 @@
185159
"cell_type": "markdown",
186160
"metadata": {},
187161
"source": [
188-
"### Step 3: Model the data\n",
189162
"<h4>Define model input data</h4>\n",
190163
"<p>\n",
191164
"The first thing to define is the model input data.\n",
@@ -208,7 +181,7 @@
208181
"cell_type": "markdown",
209182
"metadata": {},
210183
"source": [
211-
"### Step 4: Set up the prescriptive model"
184+
"### Step 3: Set up the prescriptive model"
212185
]
213186
},
214187
{
@@ -411,7 +384,7 @@
411384
"source": [
412385
"#### Solve with Decision Optimization solve service\n",
413386
"\n",
414-
"If url and key are None, the Modeling layer will look for a local runtime, otherwise will use the credentials.\n",
387+
"By default, the modeling layer look for a local runtime, but other solving environments, such as *docloud*, are also available.\n",
415388
"Look at the documentation for a good understanding of the various solving/generation modes.\n",
416389
"\n",
417390
"If you're using a Community Edition of CPLEX runtimes, depending on the size of the problem, the solve stage may fail and will need a paying subscription or product installation."
@@ -434,14 +407,14 @@
434407
"source": [
435408
"# Solve the model\n",
436409
"print(\"Solving model....\")\n",
437-
"msol = mdl.solve(url=SVC_URL, key=SVC_KEY, TimeLimit=10)"
410+
"msol = mdl.solve(TimeLimit=10)"
438411
]
439412
},
440413
{
441414
"cell_type": "markdown",
442415
"metadata": {},
443416
"source": [
444-
"### Step 6: Investigate the solution and then run an example analysis\n",
417+
"### Step 4: Investigate the solution and then run an example analysis\n",
445418
"\n",
446419
"The shortest way to output the solution that has been found by the solver is to call the method <i>print_solution()</i> as follows:"
447420
]
@@ -456,7 +429,7 @@
456429
"source": [
457430
"# Print solution\n",
458431
"print(\"Solution: \")\n",
459-
"msol.print_solution()"
432+
"msol.write()"
460433
]
461434
},
462435
{
@@ -531,7 +504,7 @@
531504
"source": [
532505
"## Summary\n",
533506
"\n",
534-
"You learned how to set up and use the IBM Decision Optimization CPLEX Modeling for Python to formulate a Constraint Programming model and solve it with IBM Decision Optimization on the cloud."
507+
"You learned how to set up and use the IBM Decision Optimization CPLEX Modeling for Python to build and solve a Constraint Programming model."
535508
]
536509
},
537510
{
@@ -549,7 +522,7 @@
549522
"cell_type": "markdown",
550523
"metadata": {},
551524
"source": [
552-
"Copyright © 2017 IBM. IPLA licensed Sample Materials."
525+
"Copyright © 2017, 2018 IBM. IPLA licensed Sample Materials."
553526
]
554527
}
555528
],

0 commit comments

Comments
 (0)