### Install PySCIPOpt via pip Source: https://pyscipopt.readthedocs.io/en/latest/_sources/install This command installs PySCIPOpt from PyPI, which provides pre-built binary wheels for various platforms. Important notes include glibc 2.28+ requirement for newer Linux versions, macOS 13+/14+ support, and potential manual SCIP installation for PySCIPOpt versions older than 4.4.0. ```bash pip install pyscipopt ``` -------------------------------- ### Install pytest for PySCIPOpt Testing Source: https://pyscipopt.readthedocs.io/en/latest/_sources/build Installs the pytest framework, which is a prerequisite for running the PySCIPOpt test suite. This command uses pip to fetch and install the testing utility. ```Bash pip install pytest ``` -------------------------------- ### Install PySCIPOpt via pip Source: https://pyscipopt.readthedocs.io/en/latest/install Use this command to install the PySCIPOpt library from the Python Package Index (PyPI). Pre-built binary wheels are provided for Linux, Windows, and MacOS. Be aware of specific glibc or macOS version requirements for newer PySCIPOpt versions. ```Shell pip install pyscipopt ``` -------------------------------- ### Install Python Build Requirements Source: https://pyscipopt.readthedocs.io/en/latest/_sources/build Installs the necessary Python packages, `setuptools` and `Cython`, required for building PySCIPOpt from source. These are installed via PyPI. ```bash pip install setuptools pip install Cython ``` -------------------------------- ### Install PySCIPOpt from Source Source: https://pyscipopt.readthedocs.io/en/latest/_sources/build Installs PySCIPOpt from the current source directory using pip. This command assumes `SCIPOPTDIR` is already set and all requirements are met. ```bash # Set environment variable SCIPOPTDIR if not yet done python -m pip install . ``` -------------------------------- ### Install pytest for PySCIPOpt Testing Source: https://pyscipopt.readthedocs.io/en/latest/build Installs the pytest framework, which is required to run the PySCIPOpt test suite. Pytest is a popular tool for writing simple, scalable tests. ```Shell pip install pytest ``` -------------------------------- ### Install PySCIPOpt using Conda Source: https://pyscipopt.readthedocs.io/en/latest/_sources/install This command installs PySCIPOpt and its SCIP dependency automatically via the Conda package manager from the conda-forge channel. It is strongly advised not to use the Conda base environment for this installation. ```bash conda install --channel conda-forge pyscipopt ``` -------------------------------- ### Install PySCIPOpt from Source Source: https://pyscipopt.readthedocs.io/en/latest/build Installs PySCIPOpt from the current source directory using pip. This command assumes SCIPOPTDIR is already set and all requirements are met. ```Shell # Set environment variable SCIPOPTDIR if not yet done python -m pip install . ``` -------------------------------- ### Setup Benders Subproblem (PySCIPOpt Model) Source: https://pyscipopt.readthedocs.io/en/latest/api/model Sets up the Benders’ subproblem given the master problem solution. ```APIDOC setupBendersSubproblem(probnumber, benders=None, solution=None, checktype=1) Parameters: probnumber: int - the index of the problem that is to be set up benders: Benders or None, optional - the Benders’ decomposition to which the subproblem belongs to solution: Solution or None, optional - the master problem solution that is used for the set up, if None, then the LP solution is used checktype: PY_SCIP_BENDERSENFOTYPE - the type of solution check that prompted the solving of the Benders’ subproblems, either PY_SCIP_BENDERSENFOTYPE: LP, RELAX, PSEUDO or CHECK. Default is LP. ``` -------------------------------- ### Build PySCIPOpt Documentation Locally Source: https://pyscipopt.readthedocs.io/en/latest/_sources/build Instructions for generating the PySCIPOpt documentation on a local machine. It first installs necessary Sphinx dependencies from docs/requirements.txt and then builds the documentation into the docs/_build directory. ```Bash pip install -r docs/requirements.txt sphinx-build docs docs/_build ``` -------------------------------- ### Install PySCIPOpt via Conda Source: https://pyscipopt.readthedocs.io/en/latest/install Install PySCIPOpt using the Conda package manager from the 'conda-forge' channel. This method automatically installs the necessary SCIP dependencies. It is advised not to use the Conda base environment for installation. ```Shell conda install --channel conda-forge pyscipopt ``` -------------------------------- ### Install Python Build Dependencies Source: https://pyscipopt.readthedocs.io/en/latest/build Install the essential Python packages, `setuptools` and `Cython`, required for the PySCIPOpt build process. It is recommended to use Cython version 3 or newer for compatibility. ```Shell pip install setuptools pip install Cython ``` -------------------------------- ### Build PySCIPOpt Documentation Locally Source: https://pyscipopt.readthedocs.io/en/latest/build Installs documentation requirements and builds the PySCIPOpt documentation locally using Sphinx. The generated documentation will be placed in the `docs/_build` directory. ```Shell pip install -r docs/requirements.txt sphinx-build docs docs/_build ``` -------------------------------- ### Build PySCIPOpt with Debug Information Source: https://pyscipopt.readthedocs.io/en/latest/build Installs PySCIPOpt from source with debug information enabled. Requires the debug library of the SCIP Optimization Suite to be available. ```Shell python -m pip install --install-option="--debug" . ``` -------------------------------- ### Example SCIP Optimization Log Output Source: https://pyscipopt.readthedocs.io/en/latest/_sources/tutorials/logfile This snippet shows a complete example of the log output generated by SCIP during an optimization run. It includes details on presolving steps, variable and constraint counts, and the main optimization progress table with metrics like time, nodes, LP iterations, memory, bounds, and gap. ```SCIP Log presolving: (round 1, fast) 136 del vars, 0 del conss, 2 add conss, 0 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs (round 2, fast) 136 del vars, 1 del conss, 2 add conss, 0 chg bounds, 132 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs (round 3, exhaustive) 136 del vars, 2 del conss, 2 add conss, 0 chg bounds, 133 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs (round 4, exhaustive) 136 del vars, 2 del conss, 2 add conss, 0 chg bounds, 133 chg sides, 0 chg coeffs, 131 upgd conss, 0 impls, 0 clqs (0.0s) probing cycle finished: starting next cycle (0.0s) symmetry computation started: requiring (bin +, int +, cont +), (fixed: bin -, int -, cont -) (0.0s) no symmetry present (symcode time: 0.00) presolving (5 rounds: 5 fast, 3 medium, 3 exhaustive): 136 deleted vars, 2 deleted constraints, 2 added constraints, 0 tightened bounds, 0 added holes, 133 changed sides, 0 changed coefficients 231 implications, 0 cliques presolved problem has 232 variables (231 bin, 0 int, 1 impl, 0 cont) and 137 constraints 53 constraints of type 6 constraints of type 78 constraints of type transformed objective value is always integral (scale: 1) Presolving Time: 0.01 time | node | left |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr| dualbound | primalbound | gap | compl. 0.0s| 1 | 0 | 409 | - | 5350k | 0 | 232 | 156 | 137 | 0 | 0 | 19 | 0 | 7.649866e+03 | -- | Inf | unknown o 0.0s| 1 | 0 | 1064 | - |feaspump| 0 | 232 | 156 | 137 | 0 | 0 | 19 | 0 | 7.650000e+03 | 8.267000e+03 | 8.07%| unknown 0.0s| 1 | 0 | 1064 | - | 5368k | 0 | 232 | 156 | 137 | 0 | 0 | 19 | 0 | 7.650000e+03 | 8.267000e+03 | 8.07%| unknown 0.0s| 1 | 0 | 1064 | - | 5422k | 0 | 232 | 156 | 137 | 0 | 0 | 19 | 0 | 7.650000e+03 | 8.267000e+03 | 8.07%| unknown 0.0s| 1 | 0 | 1067 | - | 5422k | 0 | 232 | 156 | 137 | 0 | 0 | 19 | 0 | 7.650000e+03 | 8.267000e+03 | 8.07%| unknown 0.1s| 1 | 0 | 1132 | - | 9912k | 0 | 232 | 156 | 138 | 1 | 1 | 19 | 0 | 7.659730e+03 | 8.267000e+03 | 7.93%| unknown 0.1s| 1 | 0 | 1133 | - | 9924k | 0 | 232 | 157 | 138 | 1 | 1 | 20 | 0 | 7.660000e+03 | 8.267000e+03 | 7.92%| unknown 0.1s| 1 | 0 | 1134 | - | 9924k | 0 | 232 | 157 | 138 | 1 | 1 | 20 | 0 | 7.660000e+03 | 8.267000e+03 | 7.92%| unknown 0.1s| 1 | 0 | 1210 | - | 15M | 0 | 232 | 157 | 141 | 4 | 2 | 20 | 0 | 7.671939e+03 | 8.267000e+03 | 7.76%| unknown 0.1s| 1 | 0 | 1213 | - | 15M | 0 | 232 | 159 | 141 | 4 | 2 | 22 | 0 | 7.672000e+03 | 8.267000e+03 | 7.76%| unknown 0.1s| 1 | 0 | 1280 | - | 18M | 0 | 232 | 157 | 143 | 6 | 3 | 22 | 0 | 7.685974e+03 | 8.267000e+03 | 7.56%| unknown 0.1s| 1 | 0 | 1282 | - | 18M | 0 | 232 | 157 | 143 | 6 | 3 | 22 | 0 | 7.686000e+03 | 8.267000e+03 | 7.56%| unknown 0.2s| 1 | 0 | 1353 | - | 21M | 0 | 232 | 156 | 145 | 8 | 4 | 22 | 0 | 7.701524e+03 | 8.267000e+03 | 7.34%| unknown 0.2s| 1 | 0 | 1355 | - | 21M | 0 | 232 | 156 | 145 | 8 | 4 | 22 | 0 | 7.702000e+03 | 8.267000e+03 | 7.34%| unknown 0.2s| 1 | 0 | 1435 | - | 24M | 0 | 232 | 156 | 147 | 10 | 5 | 22 | 0 | 7.706318e+03 | 8.267000e+03 | 7.28%| unknown time | node | left |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr| dualbound | primalbound | gap | compl. 0.2s| 1 | 0 | 1438 | - | 24M | 0 | 232 | 158 | 147 | 10 | 5 | 24 | 0 | 7.707000e+03 | 8.267000e+03 | 7.27%| unknown 0.2s| 1 | 0 | 1520 | - | 30M | 0 | 232 | 158 | 149 | 12 | 6 | 24 | 0 | 7.711108e+03 | 8.267000e+03 | 7.21%| unknown 0.2s| 1 | 0 | 1521 | - | 30M | 0 | 232 | 158 | 149 | 12 | 6 | 24 | 0 | 7.712000e+03 | 8.267000e+03 | 7.20%| unknown 0.2s| 1 | 0 | 1658 | - | 34M | 0 | 232 | 158 | 151 | 14 | 7 | 24 | 0 | 7.715238e+03 | 8.267000e+03 | 7.15%| unknown 0.2s| 1 | 0 | 1659 | - | 34M | 0 | 232 | 158 | 151 | 14 | 7 | 24 | 0 | 7.716000e+03 | 8.267000e+03 | 7.14%| unknown ``` -------------------------------- ### Install Python Development Files on Linux Source: https://pyscipopt.readthedocs.io/en/latest/_sources/build Installs the Python development files on Linux systems using `apt-get`. These files are crucial for compiling PySCIPOpt and prevent 'Python.h not found' errors. ```bash sudo apt-get install python3-dev # Linux ``` -------------------------------- ### Start Probing Source: https://pyscipopt.readthedocs.io/en/latest/api/model Initiates the probing process, enabling various probing-related methods such as SCIPnewProbingNode(), SCIPbacktrackProbing(), SCIPchgVarLbProbing(), SCIPchgVarUbProbing(), SCIPfixVarProbing(), SCIPpropagateProbing(), and SCIPsolveProbingLP(). ```APIDOC startProbing() Description: Initiates probing, making methods SCIPnewProbingNode(), SCIPbacktrackProbing(), SCIPchgVarLbProbing(), SCIPchgVarUbProbing(), SCIPfixVarProbing(), SCIPpropagateProbing(), SCIPsolveProbingLP(), etc available. ``` -------------------------------- ### Build PySCIPOpt with Debug Information Source: https://pyscipopt.readthedocs.io/en/latest/_sources/build This command installs PySCIPOpt from the current directory, enabling debug symbols. It requires the SCIP Optimization Suite's debug library to be pre-built for full functionality. ```Python python -m pip install --install-option="--debug" . ``` -------------------------------- ### Install Python Development Files on Linux Source: https://pyscipopt.readthedocs.io/en/latest/build This command installs the necessary Python development files (`python3-dev`) on Linux systems using the `apt-get` package manager. These files are critical for compiling Python extensions and prevent common build errors like 'Python.h not found'. ```Shell sudo apt-get install python3-dev # Linux ``` -------------------------------- ### Get All SCIP Parameters as Dictionary in PySCIPOpt Source: https://pyscipopt.readthedocs.io/en/latest/_sources/tutorials/model Shows how to retrieve all currently set SCIP parameters and their values as a dictionary using the `getParams` method. ```python param_dict = scip.getParams() ``` -------------------------------- ### Get All PySCIPOpt Parameters as Dictionary Source: https://pyscipopt.readthedocs.io/en/latest/tutorials/model This snippet illustrates how to retrieve all currently active SCIP parameters and their values as a dictionary. This can be useful for inspecting the solver's configuration at any point. ```Python param_dict = scip.getParams() ``` -------------------------------- ### Set SCIPOPTDIR Environment Variable (Windows) Source: https://pyscipopt.readthedocs.io/en/latest/_sources/build Sets the `SCIPOPTDIR` environment variable on Windows. This is crucial for PySCIPOpt to find the SCIP installation. Examples are provided for command line (cmd/Cmder/WSL) and PowerShell. ```cmd set SCIPOPTDIR= # This is done for command line interfaces (cmd, Cmder, WSL) ``` ```powershell $Env:SCIPOPTDIR = "" # This is done for command line interfaces (powershell) ``` -------------------------------- ### Initialize PySCIPOpt Model and Components Source: https://pyscipopt.readthedocs.io/en/latest/_sources/tutorials/lazycons This snippet demonstrates the initial setup for a PySCIPOpt optimization model. It imports essential classes such as "Model", "quicksum", "Conshdlr", and "SCIP_RESULT", and then instantiates a "Model" object, which serves as the foundation for defining the optimization problem. ```python from pyscipopt import Model, quicksum, Conshdlr, SCIP_RESULT scip = Model() ``` -------------------------------- ### Get PySCIPOpt Variable Solution Value from Solution Object Source: https://pyscipopt.readthedocs.io/en/latest/_sources/tutorials/vartypes This example demonstrates an alternative method to obtain a variable's solution value by querying a specific solution object. It first checks if any solutions exist, then retrieves the best solution and accesses the variable's value directly from it. ```python if scip.getNSols() >= 1: scip_sol = scip.getBestSol() var_val = scip_sol[x] ``` -------------------------------- ### Initialize PySCIPOpt Model for Matrix API Source: https://pyscipopt.readthedocs.io/en/latest/tutorials/matrix This snippet demonstrates the basic setup for using the PySCIPOpt library, specifically for the Matrix API. It imports the `Model` class and `quicksum` function, then initializes an empty optimization model instance named `scip`. ```Python from pyscipopt import Model, quicksum scip = Model() ``` -------------------------------- ### Get Dual LP Solution of a Row Source: https://pyscipopt.readthedocs.io/en/latest/api/model Gets the dual LP solution of a row. ```APIDOC getRowDualSol(row: Row) row: Row Return type: float ``` -------------------------------- ### Accessing Properties of a PySCIPOpt Row Object Source: https://pyscipopt.readthedocs.io/en/latest/_sources/tutorials/constypes This example illustrates how to retrieve various properties from a 'Row' object in PySCIPOpt, which represents a constraint in the LP. It demonstrates methods to get the left-hand side (getLhs), right-hand side (getRhs), constant shift (getConstant), columns (getCols), coefficient values (getVals), and the name of the original constraint handler type (getConsOriginConshdlrtype). These properties provide detailed insights into the constraint's current form within the LP. ```python lhs = row.getLhs() rhs = row.getRhs() constant = row.getConstant() cols = row.getCols() vals = row.getVals() origin_cons_name = row.getConsOriginConshdlrtype() ``` -------------------------------- ### Get Number of Available Readers (PySCIPOpt Model) Source: https://pyscipopt.readthedocs.io/en/latest/api/model Gets the number of readers currently available. ```APIDOC getNReaders() Returns: int ``` -------------------------------- ### Download PySCIPOpt Source Code Source: https://pyscipopt.readthedocs.io/en/latest/_sources/build These commands allow you to download the PySCIPOpt source code by cloning the repository from GitHub using either SSH (recommended) or HTTPS. ```bash git clone git@github.com:scipopt/PySCIPOpt.git ``` ```bash git clone https://github.com/scipopt/PySCIPOpt.git ``` -------------------------------- ### Example SCIP Solver Output Log Source: https://pyscipopt.readthedocs.io/en/latest/tutorials/logfile This log shows the detailed output from a SCIP solver run, including the presolving steps (variable and constraint changes, symmetry computation) and the main optimization loop (time, node, LP iterations, memory, bounds, gap, etc.). It illustrates the various stages and metrics reported by SCIP during problem solving. ```SCIP Log presolving: (round 1, fast) 136 del vars, 0 del conss, 2 add conss, 0 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs (round 2, fast) 136 del vars, 1 del conss, 2 add conss, 0 chg bounds, 132 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs (round 3, exhaustive) 136 del vars, 2 del conss, 2 add conss, 0 chg bounds, 133 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs (round 4, exhaustive) 136 del vars, 2 del conss, 2 add conss, 0 chg bounds, 133 chg sides, 0 chg coeffs, 131 upgd conss, 0 impls, 0 clqs (0.0s) probing cycle finished: starting next cycle (0.0s) symmetry computation started: requiring (bin +, int +, cont +), (fixed: bin -, int -, cont -) (0.0s) no symmetry present (symcode time: 0.00) presolving (5 rounds: 5 fast, 3 medium, 3 exhaustive): 136 deleted vars, 2 deleted constraints, 2 added constraints, 0 tightened bounds, 0 added holes, 133 changed sides, 0 changed coefficients 231 implications, 0 cliques presolved problem has 232 variables (231 bin, 0 int, 1 impl, 0 cont) and 137 constraints 53 constraints of type 6 constraints of type 78 constraints of type transformed objective value is always integral (scale: 1) Presolving Time: 0.01 time | node | left |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr| dualbound | primalbound | gap | compl. 0.0s| 1 | 0 | 409 | - | 5350k | 0 | 232 | 156 | 137 | 0 | 0 | 19 | 0 | 7.649866e+03 | -- | Inf | unknown o 0.0s| 1 | 0 | 1064 | - |feaspump| 0 | 232 | 156 | 137 | 0 | 0 | 19 | 0 | 7.650000e+03 | 8.267000e+03 | 8.07%| unknown 0.0s| 1 | 0 | 1064 | - | 5368k | 0 | 232 | 156 | 137 | 0 | 0 | 19 | 0 | 7.650000e+03 | 8.267000e+03 | 8.07%| unknown 0.0s| 1 | 0 | 1064 | - | 5422k | 0 | 232 | 156 | 137 | 0 | 0 | 19 | 0 | 7.650000e+03 | 8.267000e+03 | 8.07%| unknown 0.0s| 1 | 0 | 1067 | - | 5422k | 0 | 232 | 156 | 137 | 0 | 0 | 19 | 0 | 7.650000e+03 | 8.267000e+03 | 8.07%| unknown 0.1s| 1 | 0 | 1132 | - | 9912k | 0 | 232 | 156 | 138 | 1 | 1 | 19 | 0 | 7.659730e+03 | 8.267000e+03 | 7.93%| unknown 0.1s| 1 | 0 | 1133 | - | 9924k | 0 | 232 | 157 | 138 | 1 | 1 | 20 | 0 | 7.660000e+03 | 8.267000e+03 | 7.92%| unknown 0.1s| 1 | 0 | 1134 | - | 9924k | 0 | 232 | 157 | 138 | 1 | 1 | 20 | 0 | 7.660000e+03 | 8.267000e+03 | 7.92%| unknown 0.1s| 1 | 0 | 1210 | - | 15M | 0 | 232 | 157 | 141 | 4 | 2 | 20 | 0 | 7.671939e+03 | 8.267000e+03 | 7.76%| unknown 0.1s| 1 | 0 | 1213 | - | 15M | 0 | 232 | 159 | 141 | 4 | 2 | 22 | 0 | 7.672000e+03 | 8.267000e+03 | 7.76%| unknown 0.1s| 1 | 0 | 1280 | - | 18M | 0 | 232 | 157 | 143 | 6 | 3 | 22 | 0 | 7.685974e+03 | 8.267000e+03 | 7.56%| unknown 0.1s| 1 | 0 | 1282 | - | 18M | 0 | 232 | 157 | 143 | 6 | 3 | 22 | 0 | 7.686000e+03 | 8.267000e+03 | 7.56%| unknown 0.2s| 1 | 0 | 1353 | - | 21M | 0 | 232 | 156 | 145 | 8 | 4 | 22 | 0 | 7.701524e+03 | 8.267000e+03 | 7.34%| unknown 0.2s| 1 | 0 | 1355 | - | 21M | 0 | 232 | 156 | 145 | 8 | 4 | 22 | 0 | 7.702000e+03 | 8.267000e+03 | 7.34%| unknown 0.2s| 1 | 0 | 1435 | - | 24M | 0 | 232 | 156 | 147 | 10 | 5 | 22 | 0 | 7.706318e+03 | 8.267000e+03 | 7.28%| unknown time | node | left |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr| dualbound | primalbound | gap | compl. 0.2s| 1 | 0 | 1438 | - | 24M | 0 | 232 | 158 | 147 | 10 | 5 | 24 | 0 | 7.707000e+03 | 8.267000e+03 | 7.27%| unknown 0.2s| 1 | 0 | 1520 | - | 30M | 0 | 232 | 158 | 149 | 12 | 6 | 24 | 0 | 7.711108e+03 | 8.267000e+03 | 7.21%| unknown 0.2s| 1 | 0 | 1521 | - | 30M | 0 | 232 | 158 | 149 | 12 | 6 | 24 | 0 | 7.712000e+03 | 8.267000e+03 | 7.20%| unknown 0.2s| 1 | 0 | 1658 | - | 34M | 0 | 232 | 158 | 151 | 14 | 7 | 24 | 0 | 7.715238e+03 | 8.267000e+03 | 7.15%| unknown 0.2s| 1 | 0 | 1659 | - | 34M | 0 | 232 | 158 | 151 | 14 | 7 | 24 | 0 | 7.716000e+03 | 8.267000e+03 | 7.14%| unknown 0.3s| 1 | 0 | 1770 | - | 40M | 0 | 232 | 158 | 153 | 16 | 8 | 24 | 0 | 7.717854e+03 | 8.267000e+03 | 7.12%| unknown 0.3s| 1 | 0 | 1771 | - | 40M | 0 | 232 | 158 | 153 | 16 | 8 | 24 | 0 | 7.718000e+03 | 8.267000e+03 | 7.11%| unknown 0.3s| 1 | 0 | 1883 | - | 40M | 0 | 232 | 157 | 154 | 17 | 9 | 24 | 0 | 7.730185e+03 | 8.267000e+03 | 6.94%| unknown ``` -------------------------------- ### Get Number of Integer Variables (PySCIPOpt Model) Source: https://pyscipopt.readthedocs.io/en/latest/api/model Gets the count of integer active problem variables. ```APIDOC getNIntVars() Returns: int ``` -------------------------------- ### Get Number of Feasible Solutions (PySCIPOpt Model) Source: https://pyscipopt.readthedocs.io/en/latest/api/model Gets the total number of feasible solutions found. ```APIDOC getNCountedSols() Returns: int ``` -------------------------------- ### Initialize PySCIPOpt Model Source: https://pyscipopt.readthedocs.io/en/latest/_sources/tutorials/constypes Demonstrates how to import `Model` and `quicksum` from `pyscipopt` and initialize a new SCIP model object. This is the foundational step for defining optimization problems. ```python from pyscipopt import Model, quicksum scip = Model() ``` -------------------------------- ### Get Number of Continuous Variables (PySCIPOpt Model) Source: https://pyscipopt.readthedocs.io/en/latest/api/model Gets the count of continuous active problem variables. ```APIDOC getNContVars() Returns: int ``` -------------------------------- ### Get Number of Binary Variables (PySCIPOpt Model) Source: https://pyscipopt.readthedocs.io/en/latest/api/model Gets the count of binary active problem variables. ```APIDOC getNBinVars() Returns: int ``` -------------------------------- ### Initialize PySCIPOpt Model Source: https://pyscipopt.readthedocs.io/en/latest/tutorials/vartypes Demonstrates how to import the Model and quicksum classes from PySCIPOpt and create a new SCIP Model instance. This is a prerequisite for adding variables and constraints in PySCIPOpt. ```Python from pyscipopt import Model, quicksum scip = Model() ``` -------------------------------- ### Example SCIP Solver Branch-and-Bound Log Output Source: https://pyscipopt.readthedocs.io/en/latest/_sources/tutorials/logfile A sample log output from the SCIP solver's branch-and-bound process, illustrating the various metrics tracked during optimization. Each line snapshots the solver's state, providing real-time updates on progress, including time, node count, LP iterations, memory usage, and solution bounds. The header row defines the columns. ```text 1.3s| 1 | 0 | 3836 | - | 55M | 0 | 206 | 193 | 162 | 20 | 14 | 50 | 0 | 7.752000e+03 | 8.135000e+03 | 4.94%| unknown 1.3s| 1 | 0 | 3838 | - | 55M | 0 | 206 | 193 | 163 | 21 | 15 | 50 | 0 | 7.752000e+03 | 8.135000e+03 | 4.94%| unknown 1.3s| 1 | 0 | 3874 | - | 55M | 0 | 206 | 195 | 165 | 23 | 16 | 52 | 0 | 7.752000e+03 | 8.135000e+03 | 4.94%| unknown 1.3s| 1 | 0 | 3878 | - | 55M | 0 | 206 | 195 | 166 | 24 | 17 | 53 | 0 | 7.752000e+03 | 8.135000e+03 | 4.94%| unknown 2.0s| 1 | 2 | 4001 | - | 55M | 0 | 206 | 200 | 166 | 24 | 18 | 59 | 71 | 7.784907e+03 | 8.135000e+03 | 4.50%| unknown * 2.9s| 59 | 21 | 6175 | 44.6 |strongbr| 11 | 206 | 251 | 158 | 45 | 1 | 110 | 494 | 7.846000e+03 | 8.099000e+03 | 3.22%| 17.26% * 3.0s| 94 | 26 | 6897 | 35.7 | LP | 18 | 206 | 262 | 151 | 54 | 2 | 121 | 508 | 7.846000e+03 | 8.090000e+03 | 3.11%| 20.71% time | node | left |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr| dualbound | primalbound | gap | compl. 3.0s| 100 | 24 | 7010 | 34.7 | 85M | 18 | 206 | 268 | 146 | 54 | 0 | 127 | 511 | 7.846000e+03 | 8.090000e+03 | 3.11%| 22.99% 3.3s| 200 | 34 | 9281 | 28.7 | 109M | 18 | 206 | 294 | 156 | 104 | 1 | 153 | 539 | 7.868560e+03 | 8.090000e+03 | 2.81%| 35.07% 3.5s| 300 | 32 | 10971 | 24.8 | 109M | 18 | 206 | 307 | 146 | 134 | 0 | 166 | 546 | 7.905000e+03 | 8.090000e+03 | 2.34%| 47.01% 3.8s| 400 | 28 | 12714 | 22.9 | 109M | 18 | 206 | 322 | 146 | 159 | 0 | 181 | 557 | 7.927000e+03 | 8.090000e+03 | 2.06%| 58.37% 4.0s| 500 | 16 | 14489 | 21.9 | 109M | 18 | 206 | 328 | 148 | 196 | 0 | 187 | 565 | 7.955492e+03 | 8.090000e+03 | 1.69%| 80.54% ``` -------------------------------- ### Get Number of Leaves in Tree (PySCIPOpt Model) Source: https://pyscipopt.readthedocs.io/en/latest/api/model Gets the total number of leaf nodes in the branch-and-bound tree. ```APIDOC getNLeaves() Returns: int ``` -------------------------------- ### Get Number of Infeasible Leaf Nodes (PySCIPOpt Model) Source: https://pyscipopt.readthedocs.io/en/latest/api/model Gets the number of infeasible leaf nodes that have been processed. ```APIDOC getNInfeasibleLeaves() Returns: int ``` -------------------------------- ### Get Primal Ray for Unbounded LP Relaxation Source: https://pyscipopt.readthedocs.io/en/latest/api/model Gets primal ray causing unboundedness of the LP relaxation. ```APIDOC getPrimalRay() Return type: list of float ``` -------------------------------- ### Initialize PySCIPOpt Model Source: https://pyscipopt.readthedocs.io/en/latest/_sources/tutorials/eventhandler Demonstrates the basic initialization of a PySCIPOpt Model object, which is a prerequisite for interacting with the SCIP solver and setting up event handlers. ```python from pyscipopt import Model scip = Model() ``` -------------------------------- ### Initialize PySCIPOpt Model Object Source: https://pyscipopt.readthedocs.io/en/latest/tutorials/model This snippet demonstrates how to import the `Model` class from `pyscipopt` and create a new, empty optimization model instance. The `Model` object serves as the central entry point for defining and solving optimization problems within PySCIPOpt. ```Python from pyscipopt import Model scip = Model() ``` -------------------------------- ### Get Number of Implicit Integer Variables (PySCIPOpt Model) Source: https://pyscipopt.readthedocs.io/en/latest/api/model Gets the count of implicit integer active problem variables. ```APIDOC getNImplVars() Returns: int ``` -------------------------------- ### Get Number of Children Nodes (PySCIPOpt Model) Source: https://pyscipopt.readthedocs.io/en/latest/api/model Gets the number of children of the current focus node in the branch-and-bound tree. ```APIDOC getNChildren() Returns: int ``` -------------------------------- ### Query PySCIPOpt Model for Solution Information Source: https://pyscipopt.readthedocs.io/en/latest/tutorials/model After successfully optimizing a PySCIPOpt model, this snippet demonstrates how to retrieve key solution information such as the total solving time, the number of nodes explored, the optimal objective value, and the solution values for specific variables. ```Python solve_time = scip.getSolvingTime() num_nodes = scip.getNTotalNodes() # Note that getNNodes() is only the number of nodes for the current run (resets at restart) obj_val = scip.getObjVal() for scip_var in [x, y, z]: print(f"Variable {scip_var.name} has value {scip.getVal(scip_var)}") ``` -------------------------------- ### Get Total Number of LPs Solved (PySCIPOpt Model) Source: https://pyscipopt.readthedocs.io/en/latest/api/model Gets the total number of Linear Programs (LPs) that have been solved so far. ```APIDOC getNLPs() Returns: int ``` -------------------------------- ### PySCIPOpt SCIP_PARAMSETTING Options Source: https://pyscipopt.readthedocs.io/en/latest/tutorials/model This section documents the available options for `SCIP_PARAMSETTING`, which controls the aggressiveness and behavior of various SCIP plugins like heuristics, presolvers, and separators. ```APIDOC SCIP_PARAMSETTING: DEFAULT: set to the default values of all the plugin’s parameters FAST: the time spend for the plugin is decreased AGGRESSIVE: such that the plugin is called more aggressively OFF: turn off the plugin ``` -------------------------------- ### Get Number of Processed Nodes (PySCIPOpt Model) Source: https://pyscipopt.readthedocs.io/en/latest/api/model Gets the total number of processed nodes in the current run, including the focus node. ```APIDOC getNNodes() Returns: int ``` -------------------------------- ### Import PySCIPOpt Model Object Source: https://pyscipopt.readthedocs.io/en/latest/_sources/tutorials/model Demonstrates how to import the `Model` object from the `pyscipopt` package to begin interacting with SCIP. ```python from pyscipopt import Model scip = Model() ``` -------------------------------- ### Get Number of Objective-Limited Solutions (PySCIPOpt Model) Source: https://pyscipopt.readthedocs.io/en/latest/api/model Gets the number of feasible primal solutions found so far that respect the objective limit. ```APIDOC getNLimSolsFound() Returns: int ```