Extract and visualize information from Gurobi log files

Overview

GRBlogtools

PyPI

Extract information from Gurobi log files and generate pandas DataFrames or Excel worksheets for further processing. Also includes a wrapper for out-of-the-box interactive visualizations using the plotting library Plotly.

performance plot

Installation

python -m pip install grblogtools

It is recommended to prepend the pip install command with python -m to ensure that the package is installed using the correct Python version currently active in your environment. See CHANGELOG for added, removed or fixed functionality.

Usage

First, you need a set of Gurobi log files to compare, e.g.,

  • results from several model instances
  • comparisons of different parameter settings
  • performance variability experiments involving multiple random seed runs
  • ...

You may also use the provided grblogtools.ipynb notebook with the example data set to get started. Additionally, there is a Gurobi TechTalk demonstrating how to use grblogtools (YouTube).

Pandas/Plotly

  1. parse log files:

    import grblogtools as glt
    
    summary, timelines, rootlp = glt.get_dataframe(["run1/*.log", "run2/*.log"], timelines=True)

    Depending on your requirements, you may need to filter or modify the resulting DataFrames.

  2. draw interactive charts, preferably in a Jupyter Notebook:

    • final results from the individual runs:
    glt.plot(summary, type="box")
    • progress charts for the individual runs:
    glt.plot(timelines, y="Gap", color="Log", type="line")

    These are just examples using the Plotly Python library - of course, any other plotting library of your choice can be used to work with these DataFrames.

Excel

Convert your log files to Excel worksheets right on the command-line:

python -m grblogtools myrun.xlsx data/*.log

List all available options and how to use the command-line tool:

python -m grblogtools --help
Comments
  • Refactoring parsers

    Refactoring parsers

    @maliheha and I are working on this on my fork. These updates aims to separate the parsers for different sections of the log into submodules so things are easier to unit-test and modify as we go.

    @mattmilten no need to review for now, we'll let you know when it's in a more complete state.

    @ronaldvdv we noticed you're also adding some tests and example data - can we fold this into the refactored code? Just want to make sure we aren't duplicating work and writing tests that may eventually clash with one another. Happy to discuss and coordinate together.

    opened by simonbowly 3
  • Problem with log files without tree search log

    Problem with log files without tree search log

    For some set of log files, I'm seeing this error:

    UnboundLocalError: local variable 'tree_search_log' referenced before assignment

    I believe this relates to this line which fails if the file does not contain the data tested for in the if-statement above.

    opened by ronaldvdv 2
  • Cut name pattern too restrictive

    Cut name pattern too restrictive

    When extracting statistics about generated cuts, the pattern for matching cut names is too restrictive. It does not match Relax-and-lift which is generated for 912-glass4-0.log. I believe the hyphen is not included in the [\w ] pattern for the cut name.

    opened by ronaldvdv 1
  • header-parser

    header-parser

    This is a small PR to add the header parser. Specifically:

    • The module header_parser.py is added to the src/grblogtools folder. Reading the current code conveyed to me that there is the underlying assumption that all header log information is captured in one line. I used the same assumption. Please let me know if this is not the right assumption and I am overlooking something.
    • The module test_header_parser.py is added. It includes just two tests and running pytest from the parent folder picks up the tests.
    • The current grblogtools.py module is not refactored to reflect these changes. The plan is to do the presolve parser in the next PR (hopefully by the end of this week) and then see how the main code can change to include these changes.
    opened by maliheha 1
  • Auto-fill parameter defaults and add prettyparams options

    Auto-fill parameter defaults and add prettyparams options

    • Implemented filling of default parameter values where they are not shown in the logs
    • Added script to generate parameter defaults using gurobipy and committed these (avoids having gurobipy as a dependency or a license requirement)
    • Implemented a prettyparams keyword arg for get_dataframe which converts some parameters to categorical descriptions
    opened by simonbowly 1
  • Add parser for NoRel logs and change timelines return signature.

    Add parser for NoRel logs and change timelines return signature.

    • Adds another timeline dataframe for NoRel incumbent/bound/timing information. Note that this currently just captures NoRel's measure of elapsed time, which starts from the start of NoRel, not the start of the solve.
    • Changes the get_dataframe return signature to:
    summary, timelines = glt.get_dataframe(["run1/*.log", "run2/*.log"], timelines=True)
    

    where timelines is a dict with three dataframes: nodelog, rootlp, and norel. This seemed cleaner than extending the output tuple again, but am happy to change.

    • Adds a simple test and tox config for testing compatible python versions.
    opened by simonbowly 1
  • Parse deterministic work metric

    Parse deterministic work metric

    Implements https://github.com/Gurobi/grblogtools/issues/27 for nodelog, barrier, and simplex. Tests seem to pass but a pre-commit hook is failing (I think)...

    opened by torressa 2
  • Parse deterministic work metric

    Parse deterministic work metric

    For example, in MIP logs we parse this line but don't collect the work units info

    Explored 1466 nodes (267947 simplex iterations) in 12.83 seconds (18.68 work units)
    
    opened by simonbowly 0
  • Throw a more useful error message if no logs were parsed

    Throw a more useful error message if no logs were parsed

    If the glob pattern matches no files (which can easily happen due to a typo, or being in the wrong directory), we get this unhelpful error during post-processing:

    >>> import grblogtools as glt
    >>> glt.parse("asdjkhaskd")
    <grblogtools.api.ParseResult object at 0x1023f75b0>
    >>> glt.parse("asdjkhaskd").summary()
    Traceback (most recent call last):
      File "/Users/bowly/.pyenv/versions/3.10.3/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3800, in get_loc
        return self._engine.get_loc(casted_key)
      File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
      File "pandas/_libs/index.pyx", line 165, in pandas._libs.index.IndexEngine.get_loc
      File "pandas/_libs/hashtable_class_helper.pxi", line 5745, in pandas._libs.hashtable.PyObjectHashTable.get_item
      File "pandas/_libs/hashtable_class_helper.pxi", line 5753, in pandas._libs.hashtable.PyObjectHashTable.get_item
    KeyError: 'Version'
    

    We should throw something more useful, like a FileNotFoundError at the parsing step if no files match.

    opened by simonbowly 0
  • Incorrect status reported for incomplete logs

    Incorrect status reported for incomplete logs

    In latest master branch, if a MIP log is incomplete (i.e. cut off with no termination message for whatever reason), we might report optimal status incorrectly. For example:

    Variable types: 23522 continuous, 2343 integer (0 binary)
    
    Root barrier log...
    
    Barrier solved model in 50 iterations and 72.71 seconds (53.24 work units)
    Optimal objective -1.76339641e+08
    
    Solved with barrier
    
    Root relaxation: objective -1.763396e+08, 104343 iterations, 108.23 seconds (79.42 work units)
    
        Nodes    |    Current Node    |     Objective Bounds      |     Work
     Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
    

    here we get 'OPTIMAL' status from ContinuousParser, but no termination message from NodeLogParser.

    grblogtoolsv1 would give an 'incomplete log' warning in this situation (and report unknown status? I'm not sure).

    We should check for this with some custom logic for Status and Runtime, something like:

    • If the model is continuous, we can get Runtime and Status from ContinuousParser
    • If the model is (a) a MIP or (b) a continuous model solved as a MIP, we should ignore Runtime and Status from ContinuousParser
      • (a) We can check using model type in SingleLogParser
      • (b) Look for the message Solving as a MIP in header or presolve
    • If TerminationParser reports runtime or status, it should take precedence (this already happens)
    opened by simonbowly 2
  • Add postprocessing helpers for run labelling

    Add postprocessing helpers for run labelling

    Adds the run_label function in the postprocessing module which builds a label based on version and changed parameters.

    Example usage:

    import grblogtools as glt
    from grblogtools.postprocessing import run_label
    summary = glt.get_dataframe(["data/*.log"])
    run_label(summary)
    

    Output is a Series, the same as current "Log" column for the glass4 examples, but built from the parameter values so does not rely on the file naming convention.

    0     912-MIPFocus2-Presolve1
    1     912-Cuts2-Heuristics0.1
    2     912-Cuts2-Heuristics0.1
    3     912-MIPFocus2-Presolve1
    4     912-Cuts2-Heuristics0.1
                   ...           
    59    912-MIPFocus1-Presolve2
    60                  912-Cuts1
    61          912-Heuristics0.1
    62          912-Heuristics0.0
    63    912-Cuts2-Heuristics0.0
    Length: 64, dtype: object 
    
    opened by simonbowly 1
Owner
Gurobi Optimization
Gurobi Optimization
VDLdraw - Batch plot the log files exported from VisualDL using Matplotlib

VDLdraw Batch plot the log files exported from VisualDL using Matplotlib. At pre

Yizhou Chen 5 Sep 26, 2022
Backend app for visualizing CANedge log files in Grafana (directly from local disk or S3)

CANedge Grafana Backend - Visualize CAN/LIN Data in Dashboards This project enables easy dashboard visualization of log files from the CANedge CAN/LIN

null 13 Dec 15, 2022
Visualize and compare datasets, target values and associations, with one line of code.

In-depth EDA (target analysis, comparison, feature analysis, correlation) in two lines of code! Sweetviz is an open-source Python library that generat

Francois Bertrand 2.3k Jan 5, 2023
Visualize and compare datasets, target values and associations, with one line of code.

In-depth EDA (target analysis, comparison, feature analysis, correlation) in two lines of code! Sweetviz is an open-source Python library that generat

Francois Bertrand 1.2k Feb 18, 2021
Generate graphs with NetworkX, natively visualize with D3.js and pywebview

webview_d3 This is some PoC code to render graphs created with NetworkX natively using D3.js and pywebview. The main benifit of this approac

byt3bl33d3r 68 Aug 18, 2022
Import, visualize, and analyze SpiderFoot OSINT data in Neo4j, a graph database

SpiderFoot Neo4j Tools Import, visualize, and analyze SpiderFoot OSINT data in Neo4j, a graph database Step 1: Installation NOTE: This installs the sf

Black Lantern Security 42 Dec 26, 2022
This is a web application to visualize various famous technical indicators and stocks tickers from user

Visualizing Technical Indicators Using Python and Plotly. Currently facing issues hosting the application on heroku. As soon as I am able to I'll like

null 4 Aug 4, 2022
Python package to Create, Read, Write, Edit, and Visualize GSFLOW models

pygsflow pyGSFLOW is a python package to Create, Read, Write, Edit, and Visualize GSFLOW models API Documentation pyGSFLOW API documentation can be fo

pyGSFLOW 21 Dec 14, 2022
A small collection of tools made by me, that you can use to visualize atomic orbitals in both 2D and 3D in different aspects.

Orbitals in Python A small collection of tools made by me, that you can use to visualize atomic orbitals in both 2D and 3D in different aspects, and o

Prakrisht Dahiya 1 Nov 25, 2021
Epagneul is a tool to visualize and investigate windows event logs

epagneul Epagneul is a tool to visualize and investigate windows event logs. Dep

jurelou 190 Dec 13, 2022
This project is an Algorithm Visualizer where a user can visualize algorithms like Bubble Sort, Merge Sort, Quick Sort, Selection Sort, Linear Search and Binary Search.

Algo_Visualizer This project is an Algorithm Visualizer where a user can visualize common algorithms like "Bubble Sort", "Merge Sort", "Quick Sort", "

Rahul 4 Feb 7, 2022
WebApp served by OAK PoE device to visualize various streams, metadata and AI results

DepthAI PoE WebApp | Bootstrap 4 & Vue.js SPA Dashboard Based on dashmin (https:

Luxonis 6 Apr 9, 2022
Automatically Visualize any dataset, any size with a single line of code. Created by Ram Seshadri. Collaborators Welcome. Permission Granted upon Request.

AutoViz Automatically Visualize any dataset, any size with a single line of code. AutoViz performs automatic visualization of any dataset with one lin

AutoViz and Auto_ViML 1k Jan 2, 2023
Automatically Visualize any dataset, any size with a single line of code. Created by Ram Seshadri. Collaborators Welcome. Permission Granted upon Request.

AutoViz Automatically Visualize any dataset, any size with a single line of code. AutoViz performs automatic visualization of any dataset with one lin

AutoViz and Auto_ViML 299 Feb 13, 2021
Visualize tensors in a plain Python REPL using Sparklines

Visualize tensors in a plain Python REPL using Sparklines

Shawn Presser 43 Sep 3, 2022
Visualize the bitcoin blockchain from your local node

Project Overview A new feature in Bitcoin Core 0.20 allows users to dump the state of the blockchain (the UTXO set) using the command dumptxoutset. I'

null 18 Sep 11, 2022
A gui application to visualize various sorting algorithms using pure python.

Sorting Algorithm Visualizer A gui application to visualize various sorting algorithms using pure python. Language : Python 3 Libraries required Tkint

Rajarshi Banerjee 19 Nov 30, 2022
Visualize the training curve from the *.csv file (tensorboard format).

Training-Curve-Vis Visualize the training curve from the *.csv file (tensorboard format). Feature Custom labels Curve smoothing Support for multiple c

Luckky 7 Feb 23, 2022
Visualize your pandas data with one-line code

PandasEcharts 简介 基于pandas和pyecharts的可视化工具 安装 pip 安装 $ pip install pandasecharts 源码安装 $ git clone https://github.com/gamersover/pandasecharts $ cd pand

陈华杰 2 Apr 13, 2022