diff --git a/examples/ipython/campsite.ipynb b/examples/ipython/campsite.ipynb index c0046ed..717011c 100644 --- a/examples/ipython/campsite.ipynb +++ b/examples/ipython/campsite.ipynb @@ -42,7 +42,7 @@ }, "outputs": [], "source": [ - "!pip install docplex==0.0.24" + "!pip install docplex" ] }, { @@ -287,7 +287,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.6" + "version": "2.7.8" } }, "nbformat": 4, diff --git a/examples/ipython/kmedian.ipynb b/examples/ipython/kmedian.ipynb index 4b09295..73b0620 100644 --- a/examples/ipython/kmedian.ipynb +++ b/examples/ipython/kmedian.ipynb @@ -103,7 +103,7 @@ }, "outputs": [], "source": [ - "!pip install docplex==0.0.24" + "!pip install docplex" ] }, { @@ -469,7 +469,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.6" + "version": "2.7.8" } }, "nbformat": 4, diff --git a/examples/ipython/matchmaker.ipynb b/examples/ipython/matchmaker.ipynb index 5613678..323a464 100644 --- a/examples/ipython/matchmaker.ipynb +++ b/examples/ipython/matchmaker.ipynb @@ -51,7 +51,7 @@ }, "outputs": [], "source": [ - "!pip install docplex==0.0.24" + "!pip install docplex" ] }, { @@ -243,7 +243,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.6" + "version": "2.7.8" } }, "nbformat": 4, diff --git a/examples/ipython/n_c.ipynb b/examples/ipython/n_c.ipynb index 287f48b..7502854 100644 --- a/examples/ipython/n_c.ipynb +++ b/examples/ipython/n_c.ipynb @@ -24,7 +24,7 @@ }, "outputs": [], "source": [ - "!pip install docplex==0.0.24" + "!pip install docplex" ] }, { @@ -351,7 +351,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.6" + "version": "2.7.8" } }, "nbformat": 4, diff --git a/examples/ipython/warehouse.ipynb b/examples/ipython/warehouse.ipynb index e8c07ed..c0d6989 100644 --- a/examples/ipython/warehouse.ipynb +++ b/examples/ipython/warehouse.ipynb @@ -163,7 +163,7 @@ }, "outputs": [], "source": [ - "!pip install docplex>=0.0.24" + "!pip install docplex" ] }, { @@ -642,7 +642,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.6" + "version": "2.7.8" } }, "nbformat": 4, diff --git a/examples/ipython/whiskas.ipynb b/examples/ipython/whiskas.ipynb index 623c81b..c395403 100644 --- a/examples/ipython/whiskas.ipynb +++ b/examples/ipython/whiskas.ipynb @@ -79,7 +79,7 @@ } ], "source": [ - "!pip install docplex>=0.0.24" + "!pip install docplex" ] }, { @@ -419,21 +419,21 @@ "metadata": { "celltoolbar": "Dashboard", "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 2", "language": "python", - "name": "python3" + "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 3 + "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.4.3" + "pygments_lexer": "ipython2", + "version": "2.7.8" } }, "nbformat": 4, diff --git a/examples/modeling/nurses.py b/examples/modeling/nurses.py index 5db0a09..353df1d 100644 --- a/examples/modeling/nurses.py +++ b/examples/modeling/nurses.py @@ -251,7 +251,7 @@ def print_solution(model): print("*************************** Solution ***************************") print("Allocation By Department:") for d in model.departments: - print ("\t{}: {}".format(d, sum( + print("\t{}: {}".format(d, sum( model.nurse_assignment_vars[n, s].solution_value for n in model.nurses for s in model.shifts if s.department == d))) print("Cost By Department:") @@ -267,7 +267,7 @@ def print_solution(model): print("\t{}: total hours:{}".format(n.name, total_hours)) for s in model.shifts: if model.nurse_assignment_vars[n, s].solution_value == 1: - print ("\t\t{}: {} {}-{}".format(s.day.name, s.department, s.start_time, s.end_time)) + print("\t\t{}: {} {}-{}".format(s.day.name, s.department, s.start_time, s.end_time)) SKILLS = ["Anaesthesiology", diff --git a/examples/modeling/sport_scheduling.py b/examples/modeling/sport_scheduling.py index f8213da..aa36993 100644 --- a/examples/modeling/sport_scheduling.py +++ b/examples/modeling/sport_scheduling.py @@ -92,7 +92,6 @@ def build_sports(docloud_context=None): def solve_sports(docloud_context=None): model = build_sports(docloud_context=docloud_context) model.print_information() - model.export_as_lp() model.solve() model.report() TSolution = namedtuple("TSolution", ["week", "is_divisional", "team1", "team2"]) @@ -126,7 +125,7 @@ def solve_sports(docloud_context=None): url = "https://docloud.service.com/job_manager/rest/v1" api_key = "example api_key" """ - print("This example hits the limits of CPLEX Optimization Studio and will work only the DOcloud solve.") + print("This example hits the limits of CPLEX Optimization Studio Community Edition and will work only with the DOcloud solve or a commercial edition of CPLEX.") url = "YOUR_URL_HERE" api_key = None ctx = DOcloudContext.make_default_context(url, api_key) diff --git a/examples/workflow/cutstock.py b/examples/workflow/cutstock.py index 148bbf7..d101c05 100644 --- a/examples/workflow/cutstock.py +++ b/examples/workflow/cutstock.py @@ -78,7 +78,7 @@ def setup_objective(self): self.minimize(1 - self.scal_prod(self.use_vars, self.duals)) def get_use_values(self): - assert self.has_solution() + assert self.solution return [use_var.solution_value for use_var in self.use_vars] @@ -202,7 +202,7 @@ def run(self, context=None): curr = self.infinity status = False while loop_count < 100 and abs(best - curr) >= obj_eps: - print('\n#items={},#patterns={},#vars={}'.format(len(self.items), len(self.patterns), self.variable_stats)) + print('\n#items={},#patterns={}'.format(len(self.items), len(self.patterns))) if loop_count > 0: self.refresh_model() status = master_model.solve() @@ -212,7 +212,7 @@ def run(self, context=None): print('{}> master model fails, stop'.format(loop_count)) break else: - assert master_model.has_solution() + assert master_model.solution curr = self.objective_value print('{}> new column generation iteration, best={:g}, curr={:g}'.format(loop_count, best, curr)) duals = self.get_fill_dual_values() diff --git a/examples/workflow/lagrangian_relaxation.py b/examples/workflow/lagrangian_relaxation.py index 60182a4..91df370 100644 --- a/examples/workflow/lagrangian_relaxation.py +++ b/examples/workflow/lagrangian_relaxation.py @@ -81,7 +81,7 @@ def run_GAP_model_with_Lagrangian_relaxation(As, Bs, Cs, max_iters=101, docloud_ print("*** solve fails, stopping at iteration: %d" % loop_count) break best = mdl.objective_value - penalties = [pv.get_value() for pv in p_vars] + penalties = [pv.solution_value for pv in p_vars] print('%d> new lagrangian iteration, obj=%g, m=%s, p=%s' % (loop_count, best, str(multipliers), str(penalties))) do_stop = True @@ -95,7 +95,7 @@ def run_GAP_model_with_Lagrangian_relaxation(As, Bs, Cs, max_iters=101, docloud_ if do_stop: print("* Lagrangian relaxation succeeds, best={:g}, penalty={:g}, #iterations={}" - .format(best, total_penalty.get_value(), loop_count)) + .format(best, total_penalty.solution_value, loop_count)) break else: # update multipliers and start loop again. diff --git a/examples/workflow/load_balancing.py b/examples/workflow/load_balancing.py index f31b170..cd46d56 100644 --- a/examples/workflow/load_balancing.py +++ b/examples/workflow/load_balancing.py @@ -135,15 +135,15 @@ def run(self, docloud_context=None): def print_solution(self, do_filter_zeros=True): m = self active_servers = sorted([s for s in m.servers if m.active_var_by_server[s].solution_value == 1]) - print ("Active Servers: {}".format(active_servers)) - print ("*** User assignment ***") + print("Active Servers: {}".format(active_servers)) + print("*** User assignment ***") for (u, s) in sorted(m.assign_user_to_server_vars): if m.assign_user_to_server_vars[(u, s)].solution_value == 1: - print ("{} uses {}, migration: {}".format(u, s, "yes" if m._is_migration(u, s) else "no")) - print ("*** Servers sleeping processes ***") + print("{} uses {}, migration: {}".format(u, s, "yes" if m._is_migration(u, s) else "no")) + print("*** Servers sleeping processes ***") for s in active_servers: sleeping = sum(self.assign_user_to_server_vars[u, s].solution_value * u.sleeping for u in self.users) - print ("Server: {} #sleeping={}".format(s, sleeping)) + print("Server: {} #sleeping={}".format(s, sleeping)) SERVERS = ["server002", "server003", "server001", "server006", "server007", "server004", "server005"]