Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tutorial to include parameter emphasis and setting #909

Merged
merged 4 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/tutorials/constypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ coefficient values, and the constraint handler that created the Row.


Constraint Information
========================
======================

The Constraint object can be queried like any other object. Some of the information a Constraint
object contains is the name of the constraint handler responsible for the constraint,
Expand Down
84 changes: 83 additions & 1 deletion docs/tutorials/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,88 @@ all the parameter values that you wish to set, then one can use the command:

scip.readParams(path_to_file)

Set Plugin-wide Parameters (Aggressiveness)
===================================

We can influence the behavior of some of SCIP's plugins using ``SCIP_PARAMSETTING``. This can be applied
to the heuristics, to the presolvers, and to the separators (respectively with ``setHeuristics``,
``setPresolve``, and ``setSeparating``).

.. code-block:: python

from pyscipopt import Model, SCIP_PARAMSETTING

scip = Model()
scip.setHeuristics(SCIP_PARAMSETTING.AGGRESSIVE)

There are four parameter settings:

.. list-table:: A list of the different options and the result
:widths: 25 25
:align: center
:header-rows: 1

* - Option
- Result
* - ``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

.. note:: This is important to get dual information, as it's necessary to disable presolving and heuristics.
For more information, see the tutorial on getting :doc:`constraint information.</tutorials/constypes/>`


Set Solver Emphasis
===================

One can also instruct SCIP to focus on different aspects of the search process. To do this, import
``SCIP_PARAMEMPHASIS`` from ``pyscipopt`` and set the appropriate value. For example,
if the goal is just to find a feasible solution, then we can do the following:

.. code-block:: python

from pyscipopt import Model, SCIP_PARAMEMPHASIS

scip = Model()
scip.setEmphasis(SCIP_PARAMEMPHASIS.FEASIBILITY)

You can find below a list of the available options, alongside their meaning.

.. list-table:: Parameter emphasis summary
:widths: 25 25
:align: center
:header-rows: 1

* - Setting
- Meaning
* - ``PARAMEMPHASIS.DEFAULT``
- to use default values
* - ``PARAMEMPHASIS.COUNTER``
- to get feasible and "fast" counting process
* - ``PARAMEMPHASIS.CPSOLVER``
- to get CP like search (e.g. no LP relaxation)
* - ``PARAMEMPHASIS.EASYCIP``
- to solve easy problems fast
* - ``PARAMEMPHASIS.FEASIBILITY``
- to detect feasibility fast
* - ``PARAMEMPHASIS.HARDLP``
- to be capable to handle hard LPs
* - ``PARAMEMPHASIS.OPTIMALITY``
- to prove optimality fast
* - ``PARAMEMPHASIS.PHASEFEAS``
- to find feasible solutions during a 3 phase solution process
* - ``PARAMEMPHASIS.PHASEIMPROVE``
- to find improved solutions during a 3 phase solution process
* - ``PARAMEMPHASIS.PHASEPROOF``
- to proof optimality during a 3 phase solution process
* - ``PARAMEMPHASIS.NUMERICS``
- to solve problems which cause numerical issues

Copy a SCIP Model
==================

Expand All @@ -122,7 +204,7 @@ This model is completely independent from the source model. The data has been du
That is, calling ``scip.optimize()`` at this point will have no effect on ``scip_alternate_model``.

.. note:: After optimizing users often struggle with reoptimization. To make changes to an
already optimized model, one must first fo the following:
already optimized model, one must first do the following:

.. code-block:: python

Expand Down
Loading