From d759256343404b4d7711f4e886427ccc8c3f9b0a Mon Sep 17 00:00:00 2001 From: Radhakrishna Date: Fri, 26 May 2023 08:53:07 -0400 Subject: [PATCH] Switch to opensource solver cbc if Gurobi is not available --- .../nuclear_flowsheet_double_loop.ipynb | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/dispatches/case_studies/nuclear_case/nuclear_flowsheet_double_loop.ipynb b/dispatches/case_studies/nuclear_case/nuclear_flowsheet_double_loop.ipynb index 05018eb9..14c7a327 100644 --- a/dispatches/case_studies/nuclear_case/nuclear_flowsheet_double_loop.ipynb +++ b/dispatches/case_studies/nuclear_case/nuclear_flowsheet_double_loop.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "id": "compatible-panic", "metadata": {}, @@ -19,6 +20,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "5fddaa2d", "metadata": {}, @@ -49,6 +51,7 @@ "import sys\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", + "import pyomo.environ as pyo\n", "\n", "# Imports from the IDAES package\n", "from idaes.apps.grid_integration import Tracker\n", @@ -62,10 +65,16 @@ "from prescient.simulator import Prescient\n", "\n", "# Import nuclear flowsheet\n", - "from dispatches.case_studies.nuclear_case.nuclear_flowsheet_multiperiod_class import MultiPeriodNuclear" + "from dispatches.case_studies.nuclear_case.nuclear_flowsheet_multiperiod_class import MultiPeriodNuclear\n", + "\n", + "for solver in ('xpress_direct', 'gurobi', 'cbc'):\n", + " if pyo.SolverFactory(solver).available(exception_flag=False):\n", + " milp_solver = solver\n", + " break" ] }, { + "attachments": {}, "cell_type": "markdown", "id": "80eee487", "metadata": {}, @@ -141,6 +150,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "5d5740c5", "metadata": {}, @@ -169,6 +179,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "278f755c", "metadata": {}, @@ -191,6 +202,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "cadef696", "metadata": {}, @@ -503,6 +515,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "52783019", "metadata": {}, @@ -531,6 +544,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "770f457e", "metadata": {}, @@ -9888,9 +9902,9 @@ " \"ruc_mipgap\": 0.01,\n", " \"symbolic_solver_labels\": True,\n", " \"reserve_factor\": 0.0,\n", - " \"deterministic_ruc_solver\": \"gurobi\",\n", + " \"deterministic_ruc_solver\": milp_solver,\n", " \"output_ruc_solutions\": True,\n", - " \"sced_solver\": \"gurobi\",\n", + " \"sced_solver\": milp_solver,\n", " \"print_sced\": True,\n", " \"enforce_sced_shutdown_ramprate\": True,\n", " \"plugin\": {\n", @@ -9906,6 +9920,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "9185fe56", "metadata": {}, @@ -9914,6 +9929,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "8af866d1", "metadata": {}, @@ -9969,6 +9985,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "545e4163", "metadata": {}, @@ -10024,6 +10041,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "d3e1deab", "metadata": {}, @@ -10032,6 +10050,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "2374a7e6", "metadata": {},