Skip to content

Commit

Permalink
docplex 2.29.241
Browse files Browse the repository at this point in the history
  • Loading branch information
MLLeroux committed Jan 6, 2025
1 parent 0a8c461 commit a634c80
Show file tree
Hide file tree
Showing 171 changed files with 981 additions and 639 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
Changelog
---------

Changed in 2.28.240:
Changed in 2.29.241:
````````````````````

* each record of a solve history use a unique timestamp for its fields


Changed in 2.28.240 (2024.08):
``````````````````````````````

* In ``docplex.cp``: robustify the handling of callback messages coming from CP Optimizer
* Allows to use numpy 2.0

Changed in 2.27.239 (2024.04):
``````````````````````````````

* Allows to use numpy 2.0

Changed in 2.27.239 (2024.04):
``````````````````````````````

* PEP517, PEP518 build
* Faster PWLs from `PR#6 <https://github.com/IBMDecisionOptimization/docplex/pull/6>`__.

Expand Down
5 changes: 5 additions & 0 deletions docplex/mp/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@ def multi_objective_values(self):
"""
self_obj = self._objective
model = self.model
if not isinstance(self_obj, list) and model.has_multi_objective():
nbMultiObj = model.number_of_multi_objective_exprs
my_multiobj = model._multi_objective
return [self.get_value(my_multiobj.exprs[i]) for i in range(nbMultiObj)]
return self_obj if is_indexable(self_obj) else [self_obj]

@property
Expand Down
172 changes: 172 additions & 0 deletions docplex/util/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# --------------------------------------------------------------------------
# File: cli.py
# ---------------------------------------------------------------------------
# Licensed Materials - Property of IBM
# 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55 5655-Y21
# Copyright IBM Corporation 2023, 2024. All Rights Reserved.
#
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with
# IBM Corp.
# --------------------------------------------------------------------------
import sys
import os
import distutils.ccompiler
import subprocess
import shutil
import glob
import argparse



def get_cos_archname(bindir, so):
arch = [a for a in glob.glob("{}/**/{}".format(bindir, so), recursive=True)]
if len(arch) == 0:
return None
elif len(arch) > 1:
print("Error: multiple source files found: {}".format(arch))
return None
return os.path.basename(os.path.dirname(arch[0]))


def get_cpo_name(version):
return "cpoptimizer.exe" if sys.platform == "win32" else "cpoptimizer"


def get_so_name(version):
ext = distutils.ccompiler.new_compiler().shared_lib_extension
if sys.platform == "darwin" : ext = ".dylib"
prefix = "" if sys.platform == "win32" else "lib"
return "{}cplex{}{}".format(prefix, version, ext)


def check_file(fname, write=False):
if write:
ok = os.access(fname, os.W_OK)
if not ok:
print("Error: {} should be present and writable but is not".format(fname))
else:
ok = os.access(fname, os.R_OK)
if not ok:
print("Error: {} should be present and readable but is not".format(fname))
return ok


def get_cplex_info():
sub_program = """
try:
import cplex
print(cplex.__path__[0], cplex.__version__)
except ModuleNotFoundError as e:
print('Error: could not import module \"cplex\"')
"""

# This needs to be run as another process as there is no other
# way of unloading the 'cplex' module and since we will copy
# a new shared object over the already loaded one, leaving the
# cplex module loaded can create a segmentation fault.
out = subprocess.run(["python", "-c", sub_program], capture_output=True)
if out.returncode == 0:
stdout = out.stdout.decode("utf-8").strip().split(" ")
if stdout[0] != "Error:":
return stdout[0], stdout[1]
return None, None


def copy_so(cos):
cos = os.path.realpath(cos)
pcplex, version = get_cplex_info()

version_mneumonic = "".join(version.split(".")[:3])
so_name = get_so_name(version_mneumonic)
cpo_name = get_cpo_name(version_mneumonic)

target_bindir = os.path.dirname(sys.executable)
target_root = os.path.dirname(target_bindir)

so_targets = [t for t in glob.glob("{}/**/{}".format(target_root, so_name), recursive=True)]
cpo_targets = [t for t in glob.glob("{}/**/{}".format(target_root, cpo_name), recursive=True)]
if len(so_targets) == 0:
print("ERROR: did not find shared object file {} in {}".format(so_name, target_root))
return 1
if len(cpo_targets) == 0:
print("ERROR: did not find executable file {} in {}".format(cpo_name, target_root))
return 1

#
# Find sources so_source, cpo_target
#
bindir = os.path.join(cos, "cplex", "bin")
platform = get_cos_archname(bindir, so_name)
if platform is None:
print(
"ERROR: unable to determine COS architecture mneumonic by searching for {} in {}. Please check your COS installation".format(
so_name, bindir))
return 1

so_source = os.path.join(cos, "cplex", "bin", platform, so_name)
cpo_source = os.path.join(cos, "cpoptimizer", "bin", platform, cpo_name)

ok = check_file(so_source, False)
ok = check_file(cpo_source, False) and ok
for f in so_targets + cpo_targets:
ok = check_file(f, True)

if not ok:
return 1

#
# Make copies
#
copies = tuple((so_source, t) for t in so_targets) + tuple((cpo_source, t) for t in cpo_targets)

print("Performing copies:")
code = 0
try:
for s, t in copies:
print(" {} -> {}".format(s, t))
shutil.copyfile(s, t)
except EnvironmentError as e:
print("ERROR: Could not upgrade packages due to an EnvironmentError: {}".format(e))
print("Consider using the `--user` option or check the permissions.")
code = e.code
except Exception as e:
print("Error: Something went wrong during copying: {}".format(e))
code = 1

return code


def config(args):
if args.cos_root is not None:
if not os.path.isdir(args.cos_root):
print("ERROR: '{}' does not exist or is not a directory".format(args.cos_root))
code = 1
else:
code = copy_so(args.cos_root)

sys.exit(code)


def main():
parser = argparse.ArgumentParser(prog="docplex")

subparsers = parser.add_subparsers(dest="command", title="commands", metavar="<command>")

parser_command1 = subparsers.add_parser("config", help="Manage configuration")
parser_command1.add_argument("--upgrade", dest="cos_root", type=str,
help="Upgrade this module from a Cplex Optimization Studio installation ",
metavar="<cplex_studio_location>", required=True)
parser_command1.set_defaults(func=config)

args = parser.parse_args()

if args.command is None:
parser.print_help()
else:
args.func(args)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion docplex/util/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,9 @@ def update_solve_details(self, details, transaction=None):
def record_in_history(self, details):
self.recorded_solve_details_count += 1
self.logger.debug(lazy(lambda: f"record in history: {json.dumps(details)}"))
current_ts = round(time.time(), self.record_history_time_decimals)
for f in self.record_history_fields:
if f in details:
current_ts = round(time.time(), self.record_history_time_decimals)
current_history_element = [current_ts, details[f]]
l = self.record_history.get(f, deque([], self.record_history_size))
self.record_history[f] = l
Expand Down
6 changes: 3 additions & 3 deletions docplex/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
# This file is generated !
# See script tools/gen_version.py
docplex_version_major = 2
docplex_version_minor = 28
docplex_version_micro = 240
docplex_version_string = '2.28.240'
docplex_version_minor = 29
docplex_version_micro = 241
docplex_version_string = '2.29.241'

latest_cplex_major = 22
latest_cplex_minor = 1
28 changes: 21 additions & 7 deletions docs/CHANGELOG.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<meta charset="iso-8859-1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>Changelog &#8212; IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.28 documentation</title>
<title>Changelog &#8212; IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.29 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/bizstyle.css?v=c92c1228" />

<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js?v=3c40121d"></script>
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js?v=588fc259"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=4825356b"></script>
<script src="_static/bizstyle.js"></script>
Expand All @@ -28,7 +28,7 @@ <h3>Navigation</h3>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="nav-item nav-item-0"><a href="index.html">IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.28 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.29 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Changelog</a></li>
</ul>
</div>
Expand All @@ -40,8 +40,14 @@ <h3>Navigation</h3>

<section id="changelog">
<h1>Changelog<a class="headerlink" href="#changelog" title="Permalink to this heading">&para;</a></h1>
<section id="changed-in-2-28-240">
<h2>Changed in 2.28.240:<a class="headerlink" href="#changed-in-2-28-240" title="Permalink to this heading">&para;</a></h2>
<section id="changed-in-2-29-241">
<h2>Changed in 2.29.241:<a class="headerlink" href="#changed-in-2-29-241" title="Permalink to this heading">&para;</a></h2>
<ul class="simple">
<li><p>each record of a solve history use a unique timestamp for its fields</p></li>
</ul>
</section>
<section id="changed-in-2-28-240-2024-08">
<h2>Changed in 2.28.240 (2024.08):<a class="headerlink" href="#changed-in-2-28-240-2024-08" title="Permalink to this heading">&para;</a></h2>
<ul class="simple">
<li><p>In <code class="docutils literal notranslate"><span class="pre">docplex.cp</span></code>: robustify the handling of callback messages coming from CP Optimizer</p></li>
<li><p>Allows to use numpy 2.0</p></li>
Expand All @@ -50,6 +56,12 @@ <h2>Changed in 2.28.240:<a class="headerlink" href="#changed-in-2-28-240" title=
<section id="changed-in-2-27-239-2024-04">
<h2>Changed in 2.27.239 (2024.04):<a class="headerlink" href="#changed-in-2-27-239-2024-04" title="Permalink to this heading">&para;</a></h2>
<ul class="simple">
<li><p>Allows to use numpy 2.0</p></li>
</ul>
</section>
<section id="id1">
<h2>Changed in 2.27.239 (2024.04):<a class="headerlink" href="#id1" title="Permalink to this heading">&para;</a></h2>
<ul class="simple">
<li><p>PEP517, PEP518 build</p></li>
<li><p>Faster PWLs from <a class="reference external" href="https://github.com/IBMDecisionOptimization/docplex/pull/6">PR#6</a>.</p></li>
</ul>
Expand Down Expand Up @@ -837,8 +849,10 @@ <h2>Changed in 1.0.630:<a class="headerlink" href="#changed-in-1-0-630" title="P
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Changelog</a><ul>
<li><a class="reference internal" href="#changed-in-2-28-240">Changed in 2.28.240:</a></li>
<li><a class="reference internal" href="#changed-in-2-29-241">Changed in 2.29.241:</a></li>
<li><a class="reference internal" href="#changed-in-2-28-240-2024-08">Changed in 2.28.240 (2024.08):</a></li>
<li><a class="reference internal" href="#changed-in-2-27-239-2024-04">Changed in 2.27.239 (2024.04):</a></li>
<li><a class="reference internal" href="#id1">Changed in 2.27.239 (2024.04):</a></li>
<li><a class="reference internal" href="#changed-in-2-26-237-2023-07">Changed in 2.26.237 (2023.07):</a></li>
<li><a class="reference internal" href="#changed-in-2-25-236-2023-01">Changed in 2.25.236 (2023.01):</a></li>
<li><a class="reference internal" href="#changed-in-2-24-232-2022-11">Changed in 2.24.232 (2022.11):</a></li>
Expand Down Expand Up @@ -885,7 +899,7 @@ <h3>Navigation</h3>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="nav-item nav-item-0"><a href="index.html">IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.28 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.29 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Changelog</a></li>
</ul>
</div>
Expand Down
8 changes: 4 additions & 4 deletions docs/README.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<meta charset="iso-8859-1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>README.md &#8212; IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.28 documentation</title>
<title>README.md &#8212; IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.29 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/bizstyle.css?v=c92c1228" />

<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js?v=3c40121d"></script>
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js?v=588fc259"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=4825356b"></script>
<script src="_static/bizstyle.js"></script>
Expand All @@ -28,7 +28,7 @@ <h3>Navigation</h3>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="nav-item nav-item-0"><a href="index.html">IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.28 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.29 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">README.md</a></li>
</ul>
</div>
Expand Down Expand Up @@ -120,7 +120,7 @@ <h3>Navigation</h3>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="nav-item nav-item-0"><a href="index.html">IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.28 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.29 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">README.md</a></li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/_static/bizstyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const initialiseBizStyle = () => {
}

window.addEventListener("resize",
() => (document.querySelector("li.nav-item-0 a").innerText = (window.innerWidth <= 776) ? "Top" : "IBM® Decision Optimization CPLEX® Modeling for Python (DOcplex) V2.28 documentation")
() => (document.querySelector("li.nav-item-0 a").innerText = (window.innerWidth <= 776) ? "Top" : "IBM® Decision Optimization CPLEX® Modeling for Python (DOcplex) V2.29 documentation")
)

if (document.readyState !== "loading") initialiseBizStyle()
Expand Down
2 changes: 1 addition & 1 deletion docs/_static/documentation_options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: 'V2.28',
VERSION: 'V2.29',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
Expand Down
8 changes: 4 additions & 4 deletions docs/cp.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<meta charset="iso-8859-1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>Overview of constraint programming &#8212; IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.28 documentation</title>
<title>Overview of constraint programming &#8212; IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.29 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/bizstyle.css?v=c92c1228" />

<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js?v=3c40121d"></script>
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js?v=588fc259"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=4825356b"></script>
<script src="_static/bizstyle.js"></script>
Expand All @@ -28,7 +28,7 @@ <h3>Navigation</h3>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="nav-item nav-item-0"><a href="index.html">IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.28 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.29 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Overview of constraint programming</a></li>
</ul>
</div>
Expand Down Expand Up @@ -241,7 +241,7 @@ <h3>Navigation</h3>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="nav-item nav-item-0"><a href="index.html">IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.28 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">IBM&reg; Decision Optimization CPLEX&reg; Modeling for Python (DOcplex) V2.29 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Overview of constraint programming</a></li>
</ul>
</div>
Expand Down
Binary file modified docs/cp/.doctrees/environment.pickle
Binary file not shown.
Loading

0 comments on commit a634c80

Please sign in to comment.