Full Code of coin-or/CyLP for AI

master cada9af898ea cached
281 files
62.8 MB
11.1M tokens
485 symbols
1 requests
Copy disabled (too large) Download .txt
Showing preview only (44,426K chars total). Download the full file to get everything.
Repository: coin-or/CyLP
Branch: master
Commit: cada9af898ea
Files: 281
Total size: 62.8 MB

Directory structure:
gitextract_vql885vl/

├── .coin-or/
│   └── projDesc.xml
├── .github/
│   └── workflows/
│       ├── ci-cvxpy.yml
│       ├── cibuildwheel.yml
│       └── release.yml
├── .gitignore
├── AUTHORS
├── LICENSE
├── MANIFEST.in
├── README.rst
├── cylp/
│   ├── VERSION
│   ├── __init__.py
│   ├── cpp/
│   │   ├── .gitignore
│   │   ├── CbcCompareUser.cpp
│   │   ├── CbcCompareUser.hpp
│   │   ├── CyClpSimplex_api.h
│   │   ├── ICbc.cpp
│   │   ├── ICbc.hpp
│   │   ├── ICbcModel.cpp
│   │   ├── ICbcModel.hpp
│   │   ├── ICbcNode.cpp
│   │   ├── ICbcNode.hpp
│   │   ├── ICglCutGeneratorBase.cpp
│   │   ├── ICglCutGeneratorBase.h
│   │   ├── IClpDualRowPivotBase.cpp
│   │   ├── IClpDualRowPivotBase.h
│   │   ├── IClpPackedMatrix.cpp
│   │   ├── IClpPackedMatrix.hpp
│   │   ├── IClpPrimalColumnPivot.cpp
│   │   ├── IClpPrimalColumnPivot.h
│   │   ├── IClpPrimalColumnPivotBase.cpp
│   │   ├── IClpPrimalColumnPivotBase.h
│   │   ├── IClpSimplex.cpp
│   │   ├── IClpSimplex.hpp
│   │   ├── IClpSimplexPrimal.cpp
│   │   ├── IClpSimplexPrimal.hpp
│   │   ├── IClpSimplexPrimal_Wolfe.cpp
│   │   ├── IClpSimplexPrimal_Wolfe.hpp
│   │   ├── ICoinIndexedVector.cpp
│   │   ├── ICoinIndexedVector.hpp
│   │   ├── ICoinMP.cpp
│   │   ├── ICoinMP.hpp
│   │   ├── ICoinModel.hpp
│   │   ├── ICoinMpsIO.cpp
│   │   ├── ICoinMpsIO.hpp
│   │   ├── ICoinPackedMatrix.cpp
│   │   ├── ICoinPackedMatrix.hpp
│   │   ├── IOsiCuts.cpp
│   │   └── IOsiCuts.hpp
│   ├── cy/
│   │   ├── .gitignore
│   │   ├── CyCbcModel.pxd
│   │   ├── CyCbcModel.pyx
│   │   ├── CyCbcNode.pxd
│   │   ├── CyCbcNode.pyx
│   │   ├── CyCgl.pxd
│   │   ├── CyCgl.pyx
│   │   ├── CyCglCutGeneratorBase.pxd
│   │   ├── CyCglCutGeneratorBase.pyx
│   │   ├── CyCglTreeInfo.pxd
│   │   ├── CyCglTreeInfo.pyx
│   │   ├── CyClpDualRowPivotBase.pxd
│   │   ├── CyClpDualRowPivotBase.pyx
│   │   ├── CyClpPrimalColumnPivotBase.pxd
│   │   ├── CyClpPrimalColumnPivotBase.pyx
│   │   ├── CyClpPrimalColumnSteepest.pyx
│   │   ├── CyClpSimplex.pxd
│   │   ├── CyClpSimplex.pyx
│   │   ├── CyClpSimplex_api.h
│   │   ├── CyCoinIndexedVector.pxd
│   │   ├── CyCoinIndexedVector.pyx
│   │   ├── CyCoinModel.pxd
│   │   ├── CyCoinModel.pyx
│   │   ├── CyCoinMpsIO.pxd
│   │   ├── CyCoinMpsIO.pyx
│   │   ├── CyCoinPackedMatrix.pxd
│   │   ├── CyCoinPackedMatrix.pyx
│   │   ├── CyCutGeneratorPythonBase.pxd
│   │   ├── CyCutGeneratorPythonBase.pyx
│   │   ├── CyDantzigPivot.pxd
│   │   ├── CyDantzigPivot.pyx
│   │   ├── CyDualPivotPythonBase.pxd
│   │   ├── CyDualPivotPythonBase.pyx
│   │   ├── CyOsiCuts.pxd
│   │   ├── CyOsiCuts.pyx
│   │   ├── CyOsiSolverInterface.pxd
│   │   ├── CyOsiSolverInterface.pyx
│   │   ├── CyPEPivot.pxd
│   │   ├── CyPEPivot.pyx
│   │   ├── CyPivotPythonBase.pxd
│   │   ├── CyPivotPythonBase.pyx
│   │   ├── CySolve.py
│   │   ├── CyTest.pyx
│   │   ├── CyWolfePivot.pxd
│   │   ├── CyWolfePivot.pyx
│   │   ├── __init__.py
│   │   └── createCythonInterface.py
│   ├── doc/
│   │   ├── .gitignore
│   │   ├── Makefile
│   │   ├── mathjax.py
│   │   └── source/
│   │       ├── conf.py
│   │       ├── index.rst
│   │       └── modules/
│   │           ├── CyCbcModel.rst
│   │           ├── CyClpSimplex.rst
│   │           ├── CyCoinIndexedVector.rst
│   │           ├── CyCoinModel.rst
│   │           ├── CyCoinMpsIO.rst
│   │           ├── CyCoinPackedMatrix.rst
│   │           ├── CyPivotPythonBase.rst
│   │           ├── DantzigPivot.rst
│   │           ├── DualDantzigPivot.rst
│   │           ├── LIFOPivot.rst
│   │           ├── MostFrequentPivot.rst
│   │           ├── PivotPythonBase.rst
│   │           ├── PositiveEdgePivot.rst
│   │           ├── cy.rst
│   │           ├── modeling.rst
│   │           ├── pivots.rst
│   │           ├── py.rst
│   │           └── sparseUtil.rst
│   ├── input/
│   │   ├── aug3dcqp.qps
│   │   ├── cvxqp1_s.qps
│   │   ├── cvxqp2_s.qps
│   │   ├── fileDownloader.py
│   │   ├── h.qps
│   │   ├── hs268.qps
│   │   ├── hs268_2.qps
│   │   ├── hs268_p.qps
│   │   ├── hs35.qps
│   │   ├── hs35_2.qps
│   │   ├── netlib/
│   │   │   ├── 25fv47.mps
│   │   │   ├── 80bau3b.mps
│   │   │   ├── adlittle.mps
│   │   │   ├── afiro.mps
│   │   │   ├── agg.mps
│   │   │   ├── agg2.mps
│   │   │   ├── agg3.mps
│   │   │   ├── ascii
│   │   │   ├── bandm.mps
│   │   │   ├── beaconfd.mps
│   │   │   ├── blend.mps
│   │   │   ├── bnl1.mps
│   │   │   ├── bnl2.mps
│   │   │   ├── boeing1.mps
│   │   │   ├── boeing2.mps
│   │   │   ├── bore3d.mps
│   │   │   ├── brandy.mps
│   │   │   ├── capri.mps
│   │   │   ├── changes
│   │   │   ├── cycle.mps
│   │   │   ├── czprob.mps
│   │   │   ├── d2q06c.mps
│   │   │   ├── d6cube.mps
│   │   │   ├── degen2.mps
│   │   │   ├── degen3.mps
│   │   │   ├── dfl001.mps
│   │   │   ├── e226.mps
│   │   │   ├── etamacro.mps
│   │   │   ├── fffff800.mps
│   │   │   ├── fileDownloader.py
│   │   │   ├── finnis.mps
│   │   │   ├── fit1d.mps
│   │   │   ├── fit1p.mps
│   │   │   ├── fit2d.mps
│   │   │   ├── fit2p.mps
│   │   │   ├── forplan.mps
│   │   │   ├── ganges.mps
│   │   │   ├── gfrd-pnc.mps
│   │   │   ├── greenbea.mps
│   │   │   ├── greenbeb.mps
│   │   │   ├── grow15.mps
│   │   │   ├── grow22.mps
│   │   │   ├── grow7.mps
│   │   │   ├── israel.mps
│   │   │   ├── kb2.mps
│   │   │   ├── lotfi.mps
│   │   │   ├── maros
│   │   │   ├── maros-r7.mps
│   │   │   ├── maros.mps
│   │   │   ├── minos
│   │   │   ├── modszk1.mps
│   │   │   ├── nesm.mps
│   │   │   ├── perold.mps
│   │   │   ├── pilot.ja.mps
│   │   │   ├── pilot.mps
│   │   │   ├── pilot.we.mps
│   │   │   ├── pilot4.mps
│   │   │   ├── pilot87.mps
│   │   │   ├── pilotnov.mps
│   │   │   ├── readme
│   │   │   ├── recipe.mps
│   │   │   ├── sc105.mps
│   │   │   ├── sc205.mps
│   │   │   ├── sc50a.mps
│   │   │   ├── sc50b.mps
│   │   │   ├── scagr25.mps
│   │   │   ├── scagr7.mps
│   │   │   ├── scfxm1.mps
│   │   │   ├── scfxm2.mps
│   │   │   ├── scfxm3.mps
│   │   │   ├── scorpion.mps
│   │   │   ├── scrs8.mps
│   │   │   ├── scsd1.mps
│   │   │   ├── scsd6.mps
│   │   │   ├── scsd8.mps
│   │   │   ├── sctap1.mps
│   │   │   ├── sctap2.mps
│   │   │   ├── sctap3.mps
│   │   │   ├── seba.mps
│   │   │   ├── share1b.mps
│   │   │   ├── share2b.mps
│   │   │   ├── shell.mps
│   │   │   ├── ship04l.mps
│   │   │   ├── ship04s.mps
│   │   │   ├── ship08l.mps
│   │   │   ├── ship08s.mps
│   │   │   ├── ship12l.mps
│   │   │   ├── ship12s.mps
│   │   │   ├── sierra.mps
│   │   │   ├── stair.mps
│   │   │   ├── standata.mps
│   │   │   ├── standgub.mps
│   │   │   ├── standmps.mps
│   │   │   ├── stocfor1.mps
│   │   │   ├── stocfor2.mps
│   │   │   ├── stocfor3.old
│   │   │   ├── truss
│   │   │   ├── tuff.mps
│   │   │   ├── vtp.base.mps
│   │   │   ├── wood1p.mps
│   │   │   └── woodw.mps
│   │   ├── nsct1.mps
│   │   ├── p0033.mps
│   │   └── pp.qps
│   ├── py/
│   │   ├── Constants.py
│   │   ├── PySolve.py
│   │   ├── QP/
│   │   │   ├── GQP.py
│   │   │   ├── QP.py
│   │   │   ├── QPGen.py
│   │   │   ├── QPSReader.py
│   │   │   └── __init__.py
│   │   ├── __init__.py
│   │   ├── mip/
│   │   │   ├── CyLPCutGenerator.py
│   │   │   ├── GomoryCutGenerator.py
│   │   │   ├── NodeCompareBase.py
│   │   │   ├── SimpleNodeCompare.py
│   │   │   └── __init__.py
│   │   ├── modeling/
│   │   │   ├── CyLPModel.py
│   │   │   ├── __init__.py
│   │   │   └── test_modeling.py
│   │   ├── pivots/
│   │   │   ├── DantzigPivot.py
│   │   │   ├── DualDantzigPivot.py
│   │   │   ├── DualPivotPythonBase.py
│   │   │   ├── LIFOPivot.py
│   │   │   ├── MostFrequentPivot.py
│   │   │   ├── PivotPythonBase.py
│   │   │   ├── PositiveEdgePivot.py
│   │   │   ├── PositiveEdgeWolfePivot.py
│   │   │   ├── WolfePivot.py
│   │   │   ├── WolfePivotPE.py
│   │   │   └── __init__.py
│   │   ├── test_PySolve.py
│   │   └── utils/
│   │       ├── __init__.py
│   │       ├── readSetcovering.py
│   │       ├── sparseUtil.py
│   │       └── util.py
│   └── tests/
│       ├── __init__.py
│       ├── test_CyClpSimplex.py
│       ├── test_CyClpSimplex_CyLPModel.py
│       ├── test_CyCoinIndexedVector.py
│       ├── test_CyCoinModel.py
│       ├── test_CyCoinMpsIO.py
│       ├── test_CySolve.py
│       ├── test_IO.py
│       ├── test_IndexFactory.py
│       ├── test_MIP.py
│       ├── test_QP.py
│       ├── test_argWeightedMax.py
│       ├── test_sparseUtil.py
│       └── test_warmStart.py
├── fixBinaries.py
├── pyproject.toml
└── setup.py

================================================
FILE CONTENTS
================================================

================================================
FILE: .coin-or/projDesc.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type = "text/xsl" href = "http://www.coin-or.org/projects/autoGen.xsl"?>
<projectData xmlns="coin-or.org" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="coin-or.org http://www.coin-or.org/projects/autoGen.xsd">

  <projectBasics>
      <projectName>CyLP</projectName>
      <projectRepo>CyLP</projectRepo>

      <projectDescription>
         CyLP is a Python interface to COIN-OR's Linear and mixed-integer program solvers (CLP, CBC, and CGL).
         CyLP's unique feature is that one can use it to alter the solution process of the solvers from within Python.
         For example, one may define cut generators, branch-and-bound strategies, and primal/dual Simplex pivot rules completely in Python.
      </projectDescription>
      <projectShortDescription>
         A Python interface to Cbc, Clp, and Cgl.
      </projectShortDescription>

      <projectManager>Mehdi Towhidi, mehdi dot towhidi at kronos dot com </projectManager>

      <projectHomePage>https://github.com/coin-or/CyLP </projectHomePage>

      <projectLicense>Common Public License 1.0</projectLicense>
      <projectLicenseURL>https://opensource.org/licenses/cpl1.0.php</projectLicenseURL>

      <coinLinkedProjects>
         <coinProject>
            <repoName>Cbc</repoName>
         </coinProject>
         <coinProject>
            <repoName>Clp</repoName>
         </coinProject>
         <coinProject>
            <repoName>Cgl</repoName>
         </coinProject>
      </coinLinkedProjects>

      <otherLinkedPackages>
         <otherPackage>
            <packageName>Numpy</packageName>
            <packageURL>http://www.numpy.org</packageURL>
            <requiredOrOptional>Required</requiredOrOptional>
         </otherPackage>
         <otherPackage>
            <packageName>Scipy</packageName>
            <packageURL>http://www.scipy.org</packageURL>
            <requiredOrOptional>Required</requiredOrOptional>
         </otherPackage>
      </otherLinkedPackages>

      <projectLanguage>Python</projectLanguage>

      <developmentStatus>
        <activityStatus>Abandoned</activityStatus>
        <maturityLevel>5</maturityLevel>
      </developmentStatus>

      <testedPlatforms>
      </testedPlatforms>

      <projectCategories>
      <category>
          Interfaces
      </category>
      <category>
          Optimization deterministic linear continuous
      </category>
      <category>
          Optimization deterministic linear discrete
      </category>
      </projectCategories>
      
  </projectBasics>

  <leftMenuLinks>                                                   
     <documentation>http://mpy.github.io/CyLPdoc</documentation>
     <sourceCodeDownload>https://github.com/coin-or/CyLP/releases</sourceCodeDownload>
     <binaryDownload>https://pypi.org/project/cylp/</binaryDownload>
     <mailingList> </mailingList>
  </leftMenuLinks>

</projectData>


================================================
FILE: .github/workflows/ci-cvxpy.yml
================================================
name: Integration testing with CVXPY

on:
  pull_request:
    types: [reopened, opened, synchronize]
  push:
  workflow_dispatch:

concurrency:
  # Cancel previous runs of this workflow for the same branch
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest]  # Add ubuntu-latest when cvxpy pytest issue is solved
        numpy: [numpy] # We used to also test version 1.26.0, but now cvxpy requires numpy 2 

    runs-on: ${{ matrix.os }}

    steps:
  
      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - name: Install CBC
        run: |
          brew install coin-or-tools/coinor/cbc
          echo "PKG_CONFIG_PATH=$(brew --prefix)/opt/cbc/lib/pkgconfig:$(brew --prefix)/opt/clp/lib/pkgconfig:$(brew --prefix)/opt/cgl/lib/pkgconfig:$(brew --prefix)/opt/osi/lib/pkgconfig:$(brew --prefix)/opt/coinutils/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV

      - name: Job context
        run: |
          echo "::group::macos context"
          system_profiler SPSoftwareDataType
          echo "::endgroup::"

          python -V

          echo "::group::brew cbc info"
          brew info coin-or-tools/coinor/cbc
          echo "::endgroup::"
          
      - uses: actions/checkout@v2
        with:
          path: cylp

      - name: Install CyLP
        run: |
          python3 -m pip install --break-system-packages ./cylp

      - name: Check out CVXPY
        uses: actions/checkout@v2
        with:
          repository: cvxpy/cvxpy
          path: cvxpy

      - name: Install CVXPY
        run: |
          python3 -m pip install --break-system-packages ./cvxpy

      - name: Test CVXPY
        run: |
          python3 -m pip install --break-system-packages pytest hypothesis ${{ matrix.numpy }}
          python -m pytest --pyargs cvxpy.tests


================================================
FILE: .github/workflows/cibuildwheel.yml
================================================
name: Build and upload to PyPI
# taken from https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml

# Build on every branch push, tag push, and pull request change:
# on: [push, pull_request]
# Alternatively, to publish when a (published) GitHub Release is created, use the following:
on:
  #push:
  pull_request:
  release:
    types:
      - published

concurrency:
  # Cancel previous runs of this workflow for the same branch
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build_wheels:
    name: Build wheels on ${{ matrix.os }}, arch ${{ matrix.arch }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            arch: x86_64
          - os: ubuntu-latest
            arch: i686
          - os: ubuntu-24.04-arm
            arch: aarch64
          - os: macos-15-intel
            arch: x86_64
          - os: macos-latest
            arch: arm64
    env:
      CIBW_ARCHS: ${{ matrix.arch }}

    steps:
      - uses: actions/checkout@v4
      - name: Build wheels
        uses: pypa/cibuildwheel@v3.2.1

      - uses: actions/upload-artifact@v4
        with:
          name: cibuildwheel-${{ matrix.os }}-${{ matrix.arch }}
          path: ./wheelhouse/*.whl

  build_sdist:
    name: Build source distribution
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Build sdist
        run: pipx run build --sdist

      - uses: actions/upload-artifact@v4
        with:
          name: cibuildwheel-sdist
          path: dist/*.tar.gz

  upload_pypi:
    needs: [build_wheels, build_sdist]
    runs-on: ubuntu-latest
    environment:
      name: pypi
      url: https://pypi.org/p/cylp
    permissions:
      id-token: write

    # upload to PyPI on every tag starting with 'v'
    # if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
    # alternatively, to publish when a GitHub Release is created, use the following rule:
    if: github.event_name == 'release' && github.event.action == 'published'
    steps:
      - uses: actions/download-artifact@v4
        with:
          pattern: "cibuildwheel-*"
          path: dist
          merge-multiple: true

      - uses: pypa/gh-action-pypi-publish@release/v1


  upload_release_assets:
    needs: [build_wheels, build_sdist]
    runs-on: ubuntu-latest
    if: ${{ github.event_name == 'release'}}
    steps:
      - name: Upload artifacts to release
        uses: alexellis/upload-assets@0.4.0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          asset_paths: '["./wheelhouse/*.whl"]'


================================================
FILE: .github/workflows/release.yml
================================================
---
name: Create Release

on:
  push:
    tags:
      - 'v*'

jobs:
  create_release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.TKRALPHS_RELEASE }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          draft: false
          prerelease: false


================================================
FILE: .gitignore
================================================
*.swp
*~
.DS_Store
*.o
*.so
*.pyc
*.pyd
build/
MANIFEST
CyLP.egg*
cylp.egg-info
setup.cfg
dist/
wheelhouse/


================================================
FILE: AUTHORS
================================================
Mehdi Towhidi   (mehdi.towhidi@gerad.ca)
Dominique Orban (dominique.orban@gerad.ca)


================================================
FILE: LICENSE
================================================
Eclipse Public License - v 2.0

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.

1. DEFINITIONS
   “Contribution” means:

      a) in the case of the initial Contributor, the initial content Distributed
         under this Agreement, and
      b) in the case of each subsequent Contributor:
         i) changes to the Program, and
         ii) additions to the Program;
      where such changes and/or additions to the Program originate from and
      are Distributed by that particular Contributor. A Contribution
      “originates” from a Contributor if it was added to the Program by such
      Contributor itself or anyone acting on such Contributor's behalf.
      Contributions do not include changes or additions to the Program that
      are not Modified Works. “Contributor” means any person or entity that
      Distributes the Program.

   “Licensed Patents” mean patent claims licensable by a Contributor which are
   necessarily infringed by the use or sale of its Contribution alone or when
   combined with the Program.

   “Program” means the Contributions Distributed in accordance with this
   Agreement.

   “Recipient” means anyone who receives the Program under this Agreement or
   any Secondary License (as applicable), including Contributors.

   “Derivative Works” shall mean any work, whether in Source Code or other
   form, that is based on (or derived from) the Program and for which the
   editorial revisions, annotations, elaborations, or other modifications
   represent, as a whole, an original work of authorship.

   “Modified Works” shall mean any work in Source Code or other form that
   results from an addition to, deletion from, or modification of the contents
   of the Program, including, for purposes of clarity any new file in Source
   Code form that contains any contents of the Program. Modified Works shall
   not include works that contain only declarations, interfaces, types,
   classes, structures, or files of the Program solely in each case in order
   to link to, bind by name, or subclass the Program or Modified Works
   thereof.

   “Distribute” means the acts of a) distributing or b) making available in
   any manner that enables the transfer of a copy.

   “Source Code” means the form of a Program preferred for making
   modifications, including but not limited to software source code,
   documentation source, and configuration files.

   “Secondary License” means either the GNU General Public License, Version
   2.0, or any later versions of that license, including any exceptions or
   additional permissions as identified by the initial Contributor.

2. GRANT OF RIGHTS

   a) Subject to the terms of this Agreement, each Contributor hereby grants
   Recipient a non-exclusive, worldwide, royalty-free copyright license to
   reproduce, prepare Derivative Works of, publicly display, publicly perform,
   Distribute and sublicense the Contribution of such Contributor, if any, and
   such Derivative Works.
    
   b) Subject to the terms of this Agreement, each Contributor hereby grants
   Recipient a non-exclusive, worldwide, royalty-free patent license under
   Licensed Patents to make, use, sell, offer to sell, import and otherwise
   transfer the Contribution of such Contributor, if any, in Source Code or
   other form. This patent license shall apply to the combination of the
   Contribution and the Program if, at the time the Contribution is added by
   the Contributor, such addition of the Contribution causes such combination
   to be covered by the Licensed Patents. The patent license shall not apply
   to any other combinations which include the Contribution. No hardware per
   se is licensed hereunder.

   c) Recipient understands that although each Contributor grants the licenses
   to its Contributions set forth herein, no assurances are provided by any
   Contributor that the Program does not infringe the patent or other
   intellectual property rights of any other entity. Each Contributor
   disclaims any liability to Recipient for claims brought by any other entity
   based on infringement of intellectual property rights or otherwise. As a
   condition to exercising the rights and licenses granted hereunder, each
   Recipient hereby assumes sole responsibility to secure any other
   intellectual property rights needed, if any. For example, if a third party
   patent license is required to allow Recipient to Distribute the Program, it
   is Recipient's responsibility to acquire that license before distributing
   the Program.

   d) Each Contributor represents that to its knowledge it has sufficient
   copyright rights in its Contribution, if any, to grant the copyright
   license set forth in this Agreement.

   e) Notwithstanding the terms of any Secondary License, no Contributor makes
   additional grants to any Recipient (other than those set forth in this
   Agreement) as a result of such Recipient's receipt of the Program under the
   terms of a Secondary License (if permitted under the terms of Section 3).

3. REQUIREMENTS

3.1 If a Contributor Distributes the Program in any form, then:

   a) the Program must also be made available as Source Code, in accordance
   with section 3.2, and the Contributor must accompany the Program with a
   statement that the Source Code for the Program is available under this
   Agreement, and informs Recipients how to obtain it in a reasonable manner
   on or through a medium customarily used for software exchange; and

   b) the Contributor may Distribute the Program under a license different
   than this Agreement, provided that such license:

      i) effectively disclaims on behalf of all other Contributors all
      warranties and conditions, express and implied, including warranties or
      conditions of title and non-infringement, and implied warranties or
      conditions of merchantability and fitness for a particular purpose;

      ii) effectively excludes on behalf of all other Contributors all
      liability for damages, including direct, indirect, special, incidental
      and consequential damages, such as lost profits;

      iii) does not attempt to limit or alter the recipients' rights in the
      Source Code under section 3.2; and

      iv) requires any subsequent distribution of the Program by any party to
      be under a license that satisfies the requirements of this section 3.

3.2 When the Program is Distributed as Source Code:

    a) it must be made available under this Agreement, or if the Program (i)
    is combined with other material in a separate file or files made available
    under a Secondary License, and (ii) the initial Contributor attached to
    the Source Code the notice described in Exhibit A of this Agreement, then
    the Program may be made available under the terms of such Secondary
    Licenses, and

    b) a copy of this Agreement must be included with each copy of the
    Program.

3.3 Contributors may not remove or alter any copyright, patent, trademark,
attribution notices, disclaimers of warranty, or limitations of liability
(‘notices’) contained within the Program from any copy of the Program which
they Distribute, provided that Contributors may add their own appropriate
notices.

4. COMMERCIAL DISTRIBUTION

Commercial distributors of software may accept certain responsibilities with
respect to end users, business partners and the like. While this license is
intended to facilitate the commercial use of the Program, the Contributor who
includes the Program in a commercial product offering should do so in a manner
which does not create potential liability for other Contributors. Therefore,
if a Contributor includes the Program in a commercial product offering, such
Contributor (“Commercial Contributor”) hereby agrees to defend and indemnify
every other Contributor (“Indemnified Contributor”) against any losses,
damages and costs (collectively “Losses”) arising from claims, lawsuits and
other legal actions brought by a third party against the Indemnified
Contributor to the extent caused by the acts or omissions of such Commercial
Contributor in connection with its distribution of the Program in a commercial
product offering. The obligations in this section do not apply to any claims
or Losses relating to any actual or alleged intellectual property
infringement. In order to qualify, an Indemnified Contributor must: a)
promptly notify the Commercial Contributor in writing of such claim, and b)
allow the Commercial Contributor to control, and cooperate with the Commercial
Contributor in, the defense and any related settlement negotiations. The
Indemnified Contributor may participate in any such claim at its own expense.

For example, a Contributor might include the Program in a commercial product
offering, Product X. That Contributor is then a Commercial Contributor. If
that Commercial Contributor then makes performance claims, or offers
warranties related to Product X, those performance claims and warranties are
such Commercial Contributor's responsibility alone. Under this section, the
Commercial Contributor would have to defend claims against the other
Contributors related to those performance claims and warranties, and if a
court requires any other Contributor to pay any damages as a result, the
Commercial Contributor must pay those damages.

5. NO WARRANTY

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED
BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
responsible for determining the appropriateness of using and distributing the
Program and assumes all risks associated with its exercise of rights under
this Agreement, including but not limited to the risks and costs of program
errors, compliance with applicable laws, damage to or loss of data, programs
or equipment, and unavailability or interruption of operations.

6. DISCLAIMER OF LIABILITY

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED
BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY
LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

7. GENERAL

If any provision of this Agreement is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of the
remainder of the terms of this Agreement, and without further action by the
parties hereto, such provision shall be reformed to the minimum extent
necessary to make such provision valid and enforceable.

If Recipient institutes patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Program itself
(excluding combinations of the Program with other software or hardware)
infringes such Recipient's patent(s), then such Recipient's rights granted
under Section 2(b) shall terminate as of the date such litigation is filed.

All Recipient's rights under this Agreement shall terminate if it fails to
comply with any of the material terms or conditions of this Agreement and does
not cure such failure in a reasonable period of time after becoming aware of
such noncompliance. If all Recipient's rights under this Agreement terminate,
Recipient agrees to cease use and distribution of the Program as soon as
reasonably practicable. However, Recipient's obligations under this Agreement
and any licenses granted by Recipient relating to the Program shall continue
and survive.

Everyone is permitted to copy and distribute copies of this Agreement, but in
order to avoid inconsistency the Agreement is copyrighted and may only be
modified in the following manner. The Agreement Steward reserves the right to
publish new versions (including revisions) of this Agreement from time to
time. No one other than the Agreement Steward has the right to modify this
Agreement. The Eclipse Foundation is the initial Agreement Steward. The
Eclipse Foundation may assign the responsibility to serve as the Agreement
Steward to a suitable separate entity. Each new version of the Agreement will
be given a distinguishing version number. The Program (including
Contributions) may always be Distributed subject to the version of the
Agreement under which it was received. In addition, after a new version of the
Agreement is published, Contributor may elect to Distribute the Program
(including its Contributions) under the new version.

Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives
no rights or licenses to the intellectual property of any Contributor under
this Agreement, whether expressly, by implication, estoppel or otherwise. All
rights in the Program not expressly granted under this Agreement are reserved.
Nothing in this Agreement is intended to be enforceable by any entity that is
not a Contributor or Recipient. No third-party beneficiary rights are created
under this Agreement.



================================================
FILE: MANIFEST.in
================================================
include README.rst
include AUTHORS
include LICENSE
include cylp/VERSION
recursive-include cylp/cpp *.hpp *.h *.cpp


================================================
FILE: README.rst
================================================
CyLP
====

CyLP is a Python interface to COIN-OR’s Linear and mixed-integer program solvers
(CLP, CBC, and CGL). CyLP’s unique feature is that you can use it to alter the
solution process of the solvers from within Python. For example, you may
define cut generators, branch-and-bound strategies, and primal/dual Simplex
pivot rules completely in Python.

You may read your LP from an mps file or use the CyLP’s easy modeling
facility. Please find examples in the `documentation
<http://coin-or.github.io/CyLP/>`_.

Docker
======

If you're comfortable with Docker, you can get started right away with the container 
available on Dockerhub that comes with CyLP pre-installed. 

https://hub.docker.com/repository/docker/coinor/cylp

Otherwise, read on. 

Prerequisites and installation
==============================

On Windows: Installation as a binary wheel
------------------------------------------

On Windows, a binary wheel is available and it is not necessary to install Cbc.
Just do::

    $ python -m pip install cylp

On Linux/macOS: Installation as a binary wheel
---------------------------------------------------------

Binary wheels are available for Linux and some versions of OS X 
for some versions of Python. To see if there is a wheel available
for your platform, you can browse 

https://pypi.org/project/cylp/#files

or just try::

    $ python -m pip install cylp

In case this fails, it is most likely that there is no wheel for your platform.
In particular, there are no wheels for MacOS running on Apple Silicon. 
If you are on Linux, this can probably be addressed by switching to 
a supported Python version with, e.g., conda::

    $ conda create -n cylp python=3.9
    $ conda activate cylp
    
If all else fails, it is easy to install from source, but Cbc must be 
installed first, as detailed below. The easiest route for this is to use
conda.

On Linux/macOS with conda: Installation from source
---------------------------------------------------

To install from source, you will need to install binaries for Cbc or also build Cbc from source. 
The version should be 2.10 (recommended) or earlier 
(current master branch of Cbc will not work with this version of CyLP).

The following commands will create and activate a new conda environment with all
these prerequisites installed::

    $ conda create -n cylp coin-or-cbc cython numpy pkg-config scipy -c conda-forge
    $ conda activate cylp

Now you can install CyLP from PyPI::

    $ pip install --no-build-isolation cylp

(The option `--no-build-isolation` ensures that `cylp` uses the Python packages
installed by conda in the build phase.)

Alternatively, if you have cloned CyLP from GitHub::

    $ pip install --no-build-isolation .

On Linux/macOS with pip: Installation from source
-------------------------------------------------

You will need to install binaries for Cbc. The version should be 2.10 (recommended) or earlier 
(current master branch of Cbc will not work with this version of CyLP).
You can install Cbc by either by installing with your system's package manager, by downloading pre-built binaries,
or by building yourself from source using `coinbrew <https://github.com/coin-or/coinbrew>`_.

1. To install Cbc in Linux, the easiest way is to use a package manager. Install
   `coinor-libcbc-dev` on Ubuntu/Debian or `coin-or-Cbc-devel` on Fedora, or the
   `corresponding package on your distribution
   <https://doc.sagemath.org/html/en/reference/spkg/cbc.html#equivalent-system-packages>`_.

#. On macOS, it is easiest to install Cbc with homebrew:
         
   ``$ brew install cbc pkg-config``

You should no longer need to build Cbc from source on any platform unless for some reason, none of the
above recipes applies to you. If you do need to build from source, please go to the `Cbc <https://github.com/coin-or/Cbc>`_
project page and follow the instructions there. After building and installing, make sure to 
either set the `COIN_INSTALL_DIR` variable to point to the installation or set `PKG_CONFIG_PATH` to point to
the directory where the `.pc` files are installed. You may also need to set either `LD_LIBRARY_PATH` (Linux)
or `DYLD_LIBRARY_PATH` (macOS).

Next, build and install CyLP::

    $ python -m pip install cylp

This will build CyLP install the runtime dependencies (`install-requires`),
NumPy and `SciPy <https://scipy.org>` and build and install CyLP.

Testing your installation
=========================

Optional step:
    If you want to run the doctests (i.e. ``make doctest`` in the ``doc`` directory)
    you should also define::

        $ export CYLP_SOURCE_DIR=/Path/to/cylp

Now you can use CyLP in your python code. For example::

    >>> from cylp.cy import CyClpSimplex
    >>> s = CyClpSimplex()
    >>> s.readMps('../input/netlib/adlittle.mps')
    0
    >>> s.initialSolve()
    'optimal'
    >>> round(s.objectiveValue, 3)
    225494.963

Or simply go to CyLP and run::

    $ python -m unittest discover

to run all CyLP unit tests (this is currently broken).

Modeling Example
================

Here is an example of how to model with CyLP's modeling facility::

    import numpy as np
    from cylp.cy import CyClpSimplex
    from cylp.py.modeling.CyLPModel import CyLPArray

    s = CyClpSimplex()

    # Add variables
    x = s.addVariable('x', 3)
    y = s.addVariable('y', 2)

    # Create coefficients and bounds
    A = np.matrix([[1., 2., 0],[1., 0, 1.]])
    B = np.matrix([[1., 0, 0], [0, 0, 1.]])
    D = np.matrix([[1., 2.],[0, 1]])
    a = CyLPArray([5, 2.5])
    b = CyLPArray([4.2, 3])
    x_u= CyLPArray([2., 3.5])

    # Add constraints
    s += A * x <= a
    s += 2 <= B * x + D * y <= b
    s += y >= 0
    s += 1.1 <= x[1:3] <= x_u

    # Set the objective function
    c = CyLPArray([1., -2., 3.])
    s.objective = c * x + 2 * y.sum()

    # Solve using primal Simplex
    s.primal()
    print(s.primalVariableSolution['x'])

This is the expected output::

    Clp0006I 0  Obj 1.1 Primal inf 2.8999998 (2) Dual inf 5.01e+10 (5) w.o. free dual inf (4)
    Clp0006I 5  Obj 1.3
    Clp0000I Optimal - objective value 1.3
    [ 0.2  2.   1.1]

Documentation
=============

You may access CyLP's documentation:

1. *Online* : Please visit http://coin-or.github.io/CyLP/

2. *Offline* : To install CyLP's documentation in your repository, you need
   Sphinx (https://www.sphinx-doc.org/). You can generate the documentation by
   going to cylp/doc and run ``make html`` or ``make latex`` and access the
   documentation under cylp/doc/build. You can also run ``make doctest`` to
   perform all the doctest.
   
Who uses CyLP
=============

The following software packages make use of CyLP:

#. `CVXPY <https://www.cvxpy.org/>`_, a Python-embedded modeling language for
   convex optimization problems, uses CyLP for interfacing to CBC, which is one
   of the `supported mixed-integer solvers
   <https://www.cvxpy.org/tutorial/advanced/index.html#mixed-integer-programs>`_.

CyLP has been used in a wide range of practical and research fields. Some of the users include:

#. `PyArt <https://github.com/ARM-DOE/pyart>`_, The Python ARM Radar Toolkit,
   used by Atmospheric Radiation Measurement (U.S. Department of energy).
#. Meteorological Institute University of Bonn.
#. Sherbrooke university hospital (Centre hospitalier universitaire de Sherbrooke): CyLP is used for nurse scheduling.
#. Maisonneuve-Rosemont hospital (L'hôpital HMR): CyLP is used for  physician scheduling with preferences.
#. Lehigh University: CyLP is used to teach mixed-integer cuts.
#. IBM T. J. Watson research center
#. Saarland University, Germany




================================================
FILE: cylp/VERSION
================================================
0.93.0


================================================
FILE: cylp/__init__.py
================================================
import os
from os.path import realpath, join
currentDir = os.path.dirname(realpath(__file__))
with open(join(currentDir, 'VERSION')) as f:
    __version__ = f.read().strip()


================================================
FILE: cylp/cpp/.gitignore
================================================
back/


================================================
FILE: cylp/cpp/CbcCompareUser.cpp
================================================
// Copyright (C) 2004, International Business Machines
// Corporation and others.  All Rights Reserved.
#if defined(_MSC_VER)
// Turn off compiler warning about long names
#  pragma warning(disable:4786)
#endif
#include <cassert>
#include <cmath>
#include <cfloat>
//#define CBC_DEBUG

#include "CbcMessage.hpp"
#include "CbcModel.hpp"
#include "CbcTree.hpp"
#include "CbcCompareUser.hpp"
#include "CoinError.hpp"
#include "CoinHelperFunctions.hpp"

/** Default Constructor

*/
CbcCompareUser::CbcCompareUser(PyObject* obj, runTest_t runTest,
                    runNewSolution_t runNewSolution,
                    runEvery1000Nodes_t runEvery1000Nodes)
  : CbcCompareBase(),
    weight_(-1.0),
    saveWeight_(0.0),
    numberSolutions_(0),
    count_(0),
    treeSize_(0),
    obj(obj),
    runTest(runTest),
    runNewSolution(runNewSolution),
    runEvery1000Nodes(runEvery1000Nodes)
{
  test_=this;
}

// Constructor with weight
//CbcCompareUser::CbcCompareUser (double weight) 
//  : CbcCompareBase(),
//    weight_(weight) ,
//    saveWeight_(0.0),
//    numberSolutions_(0),
//    count_(0),
//    treeSize_(0)
//{
//  test_=this;
//}


// Copy constructor 
CbcCompareUser::CbcCompareUser ( const CbcCompareUser & rhs)
  :CbcCompareBase(rhs)

{
  weight_=rhs.weight_;
  saveWeight_ = rhs.saveWeight_;
  numberSolutions_=rhs.numberSolutions_;
  count_ = rhs.count_;
  treeSize_ = rhs.treeSize_;
  runTest = rhs.runTest;
  runNewSolution = rhs.runNewSolution;
  runEvery1000Nodes = rhs.runEvery1000Nodes;
  obj = rhs.obj;
}

// Clone
CbcCompareBase *
CbcCompareUser::clone() const
{
  return new CbcCompareUser(*this);
}

// Assignment operator 
CbcCompareUser & 
CbcCompareUser::operator=( const CbcCompareUser& rhs)
{

  if (this!=&rhs) {
    CbcCompareBase::operator=(rhs);
    weight_=rhs.weight_;
    saveWeight_ = rhs.saveWeight_;
    numberSolutions_=rhs.numberSolutions_;
    count_ = rhs.count_;
    treeSize_ = rhs.treeSize_;

    runTest = rhs.runTest;
    runNewSolution = rhs.runNewSolution;
    runEvery1000Nodes = rhs.runEvery1000Nodes;
    obj = rhs.obj;
  }
  return *this;
}

// Destructor 
CbcCompareUser::~CbcCompareUser ()
{
}

// Returns true if y better than x
bool 
CbcCompareUser::test (CbcNode * x, CbcNode * y)
{
    return this->runTest(this->obj, (ICbcNode*) x,(ICbcNode*) y);
}
// This allows method to change behavior as it is called
// after each solution
bool 
CbcCompareUser::newSolution(CbcModel * model,
			       double objectiveAtContinuous,
			       int numberInfeasibilitiesAtContinuous) 
{
    return this->runNewSolution(this->obj, (ICbcModel*)model, 
                             objectiveAtContinuous,
                             numberInfeasibilitiesAtContinuous);
}
// This allows method to change behavior 
bool 
CbcCompareUser::every1000Nodes(CbcModel * model, int numberNodes)
{
    return this->runEvery1000Nodes(this->obj, 
                                        (ICbcModel*)model, 
                                        numberNodes);
}
// Returns true if wants code to do scan with alternate criterion
bool 
CbcCompareUser::fullScan() const
{
  return false;
}
// This is alternate test function
bool 
CbcCompareUser::alternateTest (CbcNode * x, CbcNode * y)
{
  // not used
  abort();
  return false;
}


================================================
FILE: cylp/cpp/CbcCompareUser.hpp
================================================
// Copyright (C) 2002, International Business Machines
// Corporation and others.  All Rights Reserved.
#ifndef CbcCompareUser_H
#define CbcCompareUser_H

//#define NPY_NO_DEPRECATED_API

#include "CbcNode.hpp"
#include "CbcCompareBase.hpp"
#include "ICbcModel.hpp"
#include "ICbcNode.hpp"
#include "Python.h"
#include <numpy/arrayobject.h>

//class ICbcModel;



/* This is an example of a more complex rule with data
   It is default after first solution
   If weight is 0.0 then it is computed to hit first solution
   less 2%
*/
class CbcCompareUser  : public CbcCompareBase {
public:
  // Default Constructor
  CbcCompareUser (PyObject* obj, runTest_t runTest,
                    runNewSolution_t runNewSolution,
                    runEvery1000Nodes_t runEvery1000Nodes) ;
  // Constructor with weight
  //CbcCompareUser (double weight);

  // Copy constructor
  CbcCompareUser ( const CbcCompareUser &rhs);

  // Assignment operator
  CbcCompareUser & operator=( const CbcCompareUser& rhs);

  /// Clone
  virtual CbcCompareBase * clone() const;

  ~CbcCompareUser() ;
  /* This returns true if weighted value of node y is less than
     weighted value of node x */
  // Returns true if y better than x
  virtual bool test (CbcNode * x, CbcNode * y) ;
  /// This is alternate test function
  virtual bool alternateTest (CbcNode * x, CbcNode * y);
  // This allows method to change behavior as it is called
  // after each solution
  virtual bool newSolution(CbcModel * model,
			   double objectiveAtContinuous,
			   int numberInfeasibilitiesAtContinuous) ;
  /// Returns true if wants code to do scan with alternate criterion
  virtual bool fullScan() const;
  // This allows method to change behavior
  // Return true if want tree re-sorted
  virtual bool every1000Nodes(CbcModel * model,int numberNodes);

  /* if weight == -1.0 then depth first (before solution)
     if -2.0 then do breadth first just for first 1000 nodes
  */
  inline double getWeight() const
  { return weight_;}
  inline void setWeight(double weight)
  { weight_ = weight;}
protected:
  // Weight for each infeasibility
  double weight_;
  // Weight for each infeasibility - computed from solution
  double saveWeight_;
  // Number of solutions
  int numberSolutions_;
  // count
  mutable int count_;
  // Tree size (at last check)
  int treeSize_;
  runTest_t runTest;
  runEvery1000Nodes_t runEvery1000Nodes;
  runNewSolution_t runNewSolution;
  PyObject* obj;
};
#endif


================================================
FILE: cylp/cpp/CyClpSimplex_api.h
================================================
#ifndef __PYX_HAVE_API__CyClpSimplex
#define __PYX_HAVE_API__CyClpSimplex
#include "Python.h"

static void (*__pyx_f_12CyClpSimplex_CyPostPrimalRow)(IClpSimplex *) = 0;
#define CyPostPrimalRow __pyx_f_12CyClpSimplex_CyPostPrimalRow
static int (*__pyx_f_12CyClpSimplex_CyPivotIsAcceptable)(IClpSimplex *) = 0;
#define CyPivotIsAcceptable __pyx_f_12CyClpSimplex_CyPivotIsAcceptable

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;

    py_name = PyUnicode_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;

    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%s does not export expected C function %s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %s.%s has wrong signature (expected %s, got %s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

static int import_CyClpSimplex(void) {
  PyObject *module = 0;
  module = __Pyx_ImportModule("CyClpSimplex");
  if (!module) goto bad;
  if (__Pyx_ImportFunction(module, "CyPostPrimalRow", (void (**)(void))&__pyx_f_12CyClpSimplex_CyPostPrimalRow, "void (IClpSimplex *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "CyPivotIsAcceptable", (void (**)(void))&__pyx_f_12CyClpSimplex_CyPivotIsAcceptable, "int (IClpSimplex *)") < 0) goto bad;
  Py_DECREF(module); module = 0;
  return 0;
  bad:
  Py_XDECREF(module);
  return -1;
}

#endif /* !__PYX_HAVE_API__CyClpSimplex */


================================================
FILE: cylp/cpp/ICbc.cpp
================================================
#include "ICbc.hpp"

ICbcModel* CbcSolveMIP(IClpSimplex* clpModel, PyObject* obj, 
        runTest_t runTest, runNewSolution_t runNewSolution,
        runEvery1000Nodes_t runEvery1000Nodes){
    OsiClpSolverInterface solver1(clpModel);
    solver1.initialSolve();
    ICbcModel*  model = new ICbcModel(solver1);
    CbcCompareUser compare(obj, 
            runTest, 
            runNewSolution, 
            runEvery1000Nodes);
    model->setNodeComparison(compare);
    model->branchAndBound();
    return model;
}

ICbcModel* CbcSolveMIP(IClpSimplex* clpModel){
    OsiClpSolverInterface solver1(clpModel);
    solver1.initialSolve();
    ICbcModel*  model = new ICbcModel(solver1);
    model->branchAndBound();
    return model;
}



================================================
FILE: cylp/cpp/ICbc.hpp
================================================
//#define NPY_NO_DEPRECATED_API

#include "CbcConfig.h"

// For Branch and bound
#include "OsiSolverInterface.hpp"
#include "ICbcModel.hpp"

#include "OsiClpSolverInterface.hpp"
#include "ClpPresolve.hpp"
//#include "CbcCompareUser.hpp"
#include "CglProbing.hpp"
#include "IClpSimplex.hpp"
#include "CbcCompareUser.hpp"

ICbcModel* CbcSolveMIP(IClpSimplex* model,
                       PyObject* obj,
                       runTest_t runTest,
                       runNewSolution_t runNewSolution,
                       runEvery1000Nodes_t runEvery1000Nodes);

ICbcModel* CbcSolveMIP(IClpSimplex* model);



================================================
FILE: cylp/cpp/ICbcModel.cpp
================================================
#include "ICbcModel.hpp"

#include "CbcCompareUser.hpp"
#include "CbcSolver.hpp"

PyObject* ICbcModel::getPrimalVariableSolution(){

    _import_array();
    npy_intp dims = this->solver()->getNumCols();
    double* d = (double*)(this->solver()->getColSolution());
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, d );

    return Arr;
}

ICbcModel::ICbcModel(OsiClpSolverInterface& osiint):CbcModel(osiint){
    _import_array();
}

void ICbcModel::setNodeCompare(PyObject* obj,
                           runTest_t runTest, runNewSolution_t runNewSolution,
                           runEvery1000Nodes_t runEvery1000Nodes){
    CbcCompareUser compare(obj, runTest,
                           runNewSolution,runEvery1000Nodes);
    setNodeComparison(compare);

}


int ICbcModel::cbcMain(){
        // initialize
        int returnCode = -1;
	int logLevel = this->logLevel();
        const char* argv[] = {"ICbcModel", "-solve","-quit"};
        CbcMain0(*this);
	this->setLogLevel(logLevel);
        return CbcMain1(3, argv, *this);
        //const char* argv = "-solve -quit";
        //CbcSolverUsefulData solverData;
        //CbcMain0(*this, solverData);
	//this->setLogLevel(logLevel);
        //return CbcMain1(3, argv, *this, NULL, solverData);
}


================================================
FILE: cylp/cpp/ICbcModel.hpp
================================================
#ifndef ICbcModel_H
#define ICbcModel_H

//#define NPY_NO_DEPRECATED_API

//#include "ClpModel.hpp"
#include "ClpPackedMatrix.hpp"
#include "Python.h"
#include <numpy/arrayobject.h>
#include "CoinFinite.hpp"
#include "CoinPragma.hpp"
#include "CbcModel.hpp"
#include "Python.h"
#include <numpy/arrayobject.h>
#include "OsiClpSolverInterface.hpp"
#include "ICbcNode.hpp"
//#include "CbcSolver.hpp"
//#include "CbcCompareUser.hpp"

class ICbcModel;
typedef int (*runTest_t)(void *instance, ICbcNode * x, ICbcNode * y);
typedef bool (*runNewSolution_t)(void *instance,ICbcModel * model,
                       double objectiveAtContinuous,
                       int numberInfeasibilitiesAtContinuous);
typedef int (*runEvery1000Nodes_t)(void *instance,
                            ICbcModel * model,int numberNodes);



class ICbcModel : public CbcModel{
public:
    ICbcModel(OsiClpSolverInterface&);
    PyObject * getPrimalVariableSolution();

    void setNodeCompare(PyObject* obj,
                           runTest_t runTest, runNewSolution_t runNewSolution,
                           runEvery1000Nodes_t runEvery1000Nodes);
    int cbcMain();
};


#endif


================================================
FILE: cylp/cpp/ICbcNode.cpp
================================================
#include "ICbcNode.hpp"

bool ICbcNode::breakTie(ICbcNode* y){
    ICbcNode* x = this;
    assert (x);
    assert (y);
      return (x->nodeNumber()>y->nodeNumber());
}


================================================
FILE: cylp/cpp/ICbcNode.hpp
================================================
#ifndef ICbcNode_H
#define ICbcNode_H

//#define NPY_NO_DEPRECATED_API

//#include "ClpModel.hpp"
#include "ClpPackedMatrix.hpp"
#include "Python.h"
#include <numpy/arrayobject.h>
#include "CoinFinite.hpp"
#include "CoinPragma.hpp"
#include "CbcNode.hpp"
#include "Python.h"
#include <numpy/arrayobject.h>
//#include "OsiClpSolverInterface.hpp"

class ICbcNode : public CbcNode{
public:
    bool breakTie(ICbcNode* y);
};


#endif


================================================
FILE: cylp/cpp/ICglCutGeneratorBase.cpp
================================================
#include "ICglCutGeneratorBase.h"

void
CppCglCutGeneratorBase::generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
                 const CglTreeInfo info)
{
	//std::cout << "::Cy..Base::generateCuts()...\n";
    if (this->obj && this->runGenerateCuts) {
    	this->runGenerateCuts(this->obj, &si, &cs, info);
        return;
	}
	std::cout << "** generateCuts: invalid cy-state: obj [" << this->obj << "] fct: ["
	          << this->runGenerateCuts << "]\n";
}

CglCutGenerator * CppCglCutGeneratorBase::clone() const {
	//std::cout << "::Cy..Base::clone()...\n";
	if (this->obj && this->runCglClone) {
		return this->runCglClone(this->obj);
	}
	std::cerr << "** clone: invalid cy-state: obj [" << this->obj << "] fct: ["
	          << this->runCglClone << "]\n";
	return NULL;
}


CppCglCutGeneratorBase::CppCglCutGeneratorBase(PyObject *obj, runGenerateCuts_t runGenerateCuts,
													   runCglClone_t runCglClone) :
  obj(obj),
	runCglClone(runCglClone),
  runGenerateCuts(runGenerateCuts)
{
}

CppCglCutGeneratorBase::~CppCglCutGeneratorBase()
{
}


CppCglCutGeneratorBase::CppCglCutGeneratorBase(const CglCutGenerator & source):
    CglCutGenerator(source),
    obj(obj),
    runCglClone(runCglClone),
    runGenerateCuts(runGenerateCuts)
{
}


CppCglCutGeneratorBase::CppCglCutGeneratorBase():
    CglCutGenerator(),
    obj(obj),
    runCglClone(runCglClone),
    runGenerateCuts(runGenerateCuts)
{
}



================================================
FILE: cylp/cpp/ICglCutGeneratorBase.h
================================================
#include "Python.h"
#include <iostream>
using namespace std;

#include "CglCutGenerator.hpp"
//#include "CoinIndexedVector.hpp"
//#include "IClpSimplex.hpp"
//#include "ClpSimplex.hpp"
//#include "ClpFactorization.hpp"
#include "OsiSolverInterface.hpp"

typedef CglCutGenerator* (*runCglClone_t)(void *instance);

typedef void (*runGenerateCuts_t)(void *instance,
                const OsiSolverInterface *si, OsiCuts *cs, const CglTreeInfo info);


class CppCglCutGeneratorBase : public CglCutGenerator
{
public:
  	PyObject *obj;
	runCglClone_t runCglClone;
	runGenerateCuts_t runGenerateCuts;


	//IClpSimplex model_;

  	CppCglCutGeneratorBase(PyObject *obj, runGenerateCuts_t ,
							 runCglClone_t );
  	virtual ~CppCglCutGeneratorBase();
    CppCglCutGeneratorBase(const CglCutGenerator & source);
    CppCglCutGeneratorBase();

	virtual CglCutGenerator * clone() const;

  virtual void generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
                 const CglTreeInfo info = CglTreeInfo());


};




================================================
FILE: cylp/cpp/IClpDualRowPivotBase.cpp
================================================
#include "IClpDualRowPivotBase.h"
#include "ICoinIndexedVector.hpp"

int
CppClpDualRowPivotBase::pivotRow()
{
    //std::cout << "::Cy..Base::pivotRow()...\n";
    if (this->obj && this->runPivotRow) {
        return this->runPivotRow(this->obj);
    }
    std::cerr << "** pivotRow: invalid cy-state: obj [" << this->obj << "] fct: ["
    << this->runPivotRow << "]\n";
    return -100;
}

ClpDualRowPivot * CppClpDualRowPivotBase::clone(bool copyData) const {
    //std::cout << "::Cy..Base::clone()...\n";
    if (this->obj && this->runDualPivotClone) {
        return this->runDualPivotClone(this->obj,copyData);
    }
    std::cerr << "** clone: invalid cy-state: obj [" << this->obj << "] fct: ["
    << this->runDualPivotClone << "]\n";
    return NULL;
}

double CppClpDualRowPivotBase::updateWeights(CoinIndexedVector * input,
                                  CoinIndexedVector * spare,
                                  CoinIndexedVector * spare2,
                                  CoinIndexedVector * updatedColumn) {
    if (this->obj && this->runUpdateWeights) {
        return this->runUpdateWeights(this->obj, input, spare, spare2, updatedColumn);
    }
    std::cerr << "** clone: invalid cy-state: obj [" << this->obj << "] fct: ["
    << this->runUpdateWeights << "]\n";
    return -1;
}

void CppClpDualRowPivotBase::updatePrimalSolution(
                                       CoinIndexedVector * primalUpdate,
                                       double primalRatio,
                                       double & objectiveChange){
     if (this->obj && this->runUpdatePrimalSolution) {
        return this->runUpdatePrimalSolution(this->obj, primalUpdate,
                                                primalRatio, &objectiveChange);
         }
     std::cerr << "** clone: invalid cy-state: obj [" << this->obj << "] fct: ["
     << this->runUpdatePrimalSolution << "]\n";
     return;

}


CppClpDualRowPivotBase::CppClpDualRowPivotBase(PyObject *obj,
                                    runPivotRow_t runPivotRow,
                                    runDualPivotClone_t runDualPivotClone,
                                    runUpdateWeights_t runUpdateWeights,
                                    runUpdatePrimalSolution_t runUpdatePrimalSolution) :
    obj(obj),
    runPivotRow(runPivotRow),
    runDualPivotClone(runDualPivotClone),
    runUpdateWeights(runUpdateWeights),
    runUpdatePrimalSolution(runUpdatePrimalSolution)
{
}

CppClpDualRowPivotBase::~CppClpDualRowPivotBase()
{
}

void CppClpDualRowPivotBase::setModel(IClpSimplex* m)
{
    ClpSimplex* s = static_cast<ClpSimplex*>(m);
    model_ = s;
}

IClpSimplex* CppClpDualRowPivotBase::model()
{
    return static_cast<IClpSimplex*> (model_);
}





================================================
FILE: cylp/cpp/IClpDualRowPivotBase.h
================================================
#include "Python.h"
#include <iostream>
using namespace std;

#include "ClpDualRowPivot.hpp"
#include "CoinIndexedVector.hpp"
#include "IClpSimplex.hpp"
//#include "ClpSimplex.hpp"
#include "ClpFactorization.hpp"

typedef int (*runPivotRow_t)(void *instance);

typedef ClpDualRowPivot* (*runDualPivotClone_t)(void *instance, bool copyData);

typedef double (*runUpdateWeights_t)(void *instance,
                                  CoinIndexedVector * input,
                                  CoinIndexedVector * spare,
                                  CoinIndexedVector * spare2,
                                  CoinIndexedVector * updatedColumn);

typedef void (*runUpdatePrimalSolution_t)(void *instance,
                                       CoinIndexedVector * input,
                                       double theta,
                                       double * changeInObjective);



class CppClpDualRowPivotBase : public ClpDualRowPivot
{
public:
  	PyObject *obj;
  	runPivotRow_t runPivotRow;
	runDualPivotClone_t runDualPivotClone;
	runUpdateWeights_t runUpdateWeights;
    runUpdatePrimalSolution_t runUpdatePrimalSolution;

	//IClpSimplex model_;

  	CppClpDualRowPivotBase(PyObject *obj, runPivotRow_t ,
							 runDualPivotClone_t , runUpdateWeights_t, runUpdatePrimalSolution_t );
  	virtual ~CppClpDualRowPivotBase();

	virtual ClpDualRowPivot * clone(bool copyData = true) const;
	//virtual void saveWeights(IClpSimplex * model,int mode);
  	virtual double updateWeights(CoinIndexedVector * input,
                                  CoinIndexedVector * spare,
                                  CoinIndexedVector * spare2,
                                  CoinIndexedVector * updatedColumn);

  	virtual void updatePrimalSolution(CoinIndexedVector * input,
                                       double theta,
                                       double& changeInObjective);

    virtual int pivotRow();

	void setModel(IClpSimplex* m);
	IClpSimplex* model();
};




================================================
FILE: cylp/cpp/IClpPackedMatrix.cpp
================================================
#include "IClpPackedMatrix.hpp"

void 
IClpPackedMatrix::transposeTimesSubsetAll( IClpSimplex* model, int number,
        const long long int * which,
        const double * COIN_RESTRICT x, double * COIN_RESTRICT y,
        const double * COIN_RESTRICT rowScale, 
        const double * COIN_RESTRICT columnScale,
        double * COIN_RESTRICT spare) const
{
    // get matrix data pointers
    const int *  row = matrix_->getIndices();
    const CoinBigIndex *  columnStart = matrix_->getVectorStarts();
    const double *  elementByColumn = matrix_->getElements();
    if (!spare||!rowScale) {
        if (rowScale) {
            for (int jColumn=0;jColumn<number;jColumn++) {
                int iColumn = which[jColumn];
                CoinBigIndex j;
                CoinBigIndex start=columnStart[iColumn];
                CoinBigIndex next=columnStart[iColumn+1];
                double value=0.0;
                if (iColumn > model->getNumCols()){
                    int jRow = iColumn - model->getNumCols();
                    value = x[jRow]* -1 *rowScale[jRow];
                }
                else{
                    for (j=start;j<next;j++) {
                        int jRow=row[j];
                        value += x[jRow]*elementByColumn[j]*rowScale[jRow];
                    }
                }
                y[iColumn] -= value*columnScale[iColumn];
            }
        } else {
            for (int jColumn=0;jColumn<number;jColumn++) {
                int iColumn = which[jColumn];
                CoinBigIndex j;
                CoinBigIndex start=columnStart[iColumn];
                CoinBigIndex next=columnStart[iColumn+1];
                double value=0.0;
                if (iColumn > model->getNumCols()){
                    int jRow = iColumn - model->getNumCols();
                    value = x[jRow]* -1;
                }
                else{
                    for (j=start;j<next;j++) {
                        int jRow=row[j];
                        value += x[jRow]*elementByColumn[j];
                    }
                }
                y[iColumn] -= value;
            }
        }
  } else {
    // can use spare region
    int iRow;
    int numberRows = matrix_->getNumRows();
    for (iRow=0;iRow<numberRows;iRow++) {
      double value = x[iRow];
      if (value) 
	spare[iRow] = value*rowScale[iRow];
      else
	spare[iRow]=0.0;
    }
    for (int jColumn=0;jColumn<number;jColumn++) {
      int iColumn = which[jColumn];
      CoinBigIndex j;
      CoinBigIndex start=columnStart[iColumn];
      CoinBigIndex next=columnStart[iColumn+1];
      double value=0.0;
      for (j=start;j<next;j++) {
	int jRow=row[j];
	value += spare[jRow]*elementByColumn[j];
      }
      y[iColumn] -= value*columnScale[iColumn];
    }
  }
}



================================================
FILE: cylp/cpp/IClpPackedMatrix.hpp
================================================
#ifndef IClpPackedMatrix_H
#define IClpPackedMatrix_H

//#define NPY_NO_DEPRECATED_API

//#include "ClpModel.hpp"
#include "ClpPackedMatrix.hpp"
#include "Python.h"
#include <numpy/arrayobject.h>
#include "CoinFinite.hpp"
#include "CoinPragma.hpp"
#include "IClpSimplex.hpp"

class IClpPackedMatrix : public ClpPackedMatrix{
public:
    IClpPackedMatrix();
   
    void transposeTimesSubsetAll(IClpSimplex* model,  int number,
        const long long int * which,
        const double * COIN_RESTRICT x, double *  y,
        const double *  rowScale, 
        const double *  columnScale,
        double *  spare) const;

};


#endif


================================================
FILE: cylp/cpp/IClpPrimalColumnPivot.cpp
================================================
#include "IClpPrimalColumnPivot.h"

int CppClpPrimalColumnPivotBase::pivotColumn(CoinIndexedVector * updates,
			  CoinIndexedVector * spareRow1,
			  CoinIndexedVector * spareRow2,
			  CoinIndexedVector * spareColumn1,
			  CoinIndexedVector * spareColumn2)
{
std::cout << "PivotColumn should be implemented in a derived class\n";
return -100;
}


CppClpPrimalColumnPivotBase::CppClpPrimalColumnPivotBase(PyObject *obj, RunFct fct) :
  obj(obj),
  fct(fct)
{
}

CppClpPrimalColumnPivotBase::~CppClpPrimalColumnPivotBase()
{
}

void CppClpPrimalColumnPivotBase::saveWeights(ClpSimplex * model,int mode)
{
std::cout << "saveWeight should be implemented in a derived class\n";
}

CppClpPrimalColumnPivotBase* CppClpPrimalColumnPivotBase::clone(bool copyData) const
{
std::cout << "clone should be implemented in a derived class\n";
return 0;
}



================================================
FILE: cylp/cpp/IClpPrimalColumnPivot.h
================================================
#include "ClpPrimalColumnPivot.hpp"
#include "CoinIndexedVector.hpp"
#include "Python.h"

#include <iostream>

typedef void (*RunFct)(void *instance);

class CppClpPrimalColumnPivotBase : public ClpPrimalColumnPivot
{
public:
  PyObject *obj;
  RunFct fct;

  CppClpPrimalColumnPivotBase(PyObject *obj, RunFct fct);
  virtual ~CppClpPrimalColumnPivotBase();

virtual int pivotColumn(CoinIndexedVector * updates,
			  CoinIndexedVector * spareRow1,
			  CoinIndexedVector * spareRow2,
			  CoinIndexedVector * spareColumn1,
			  CoinIndexedVector * spareColumn2);

virtual void saveWeights(ClpSimplex * model,int mode);

virtual CppClpPrimalColumnPivotBase* clone(bool copyData = true) const;

};


================================================
FILE: cylp/cpp/IClpPrimalColumnPivotBase.cpp
================================================
#include "IClpPrimalColumnPivotBase.h"
#include "ICoinIndexedVector.hpp"

int
CppClpPrimalColumnPivotBase::pivotColumn(CoinIndexedVector* updates, CoinIndexedVector* spareRow1,
								   CoinIndexedVector* spareRow2, CoinIndexedVector* spareColumn1,
								   CoinIndexedVector* spareColumn2 )
{
	//std::cout << "::Cy..Base::pivotColumn()...\n";
	if (this->obj && this->runPivotColumn) {
		return this->runPivotColumn(this->obj, updates, spareRow1, spareRow2, spareColumn1, spareColumn2);
	}
	std::cerr << "** pivotColumn: invalid cy-state: obj [" << this->obj << "] fct: ["
	<< this->runPivotColumn << "]\n";
	return -100;
}

ClpPrimalColumnPivot * CppClpPrimalColumnPivotBase::clone(bool copyData) const {
	//std::cout << "::Cy..Base::clone()...\n";
	if (this->obj && this->runClone) {
		return this->runClone(this->obj,copyData);
	}
	std::cerr << "** clone: invalid cy-state: obj [" << this->obj << "] fct: ["
	<< this->runClone << "]\n";
	return NULL;
}

void CppClpPrimalColumnPivotBase::saveWeights(ClpSimplex * model,int mode)
{
	IClpSimplex* m = static_cast<IClpSimplex*>(model);
	if (this->obj && this->runSaveWeights) {
		this->runSaveWeights(this->obj,m, mode);
	return;
	}
	std::cerr << "** saveWeights: invalid cy-state: obj [" << this->obj << "] fct: ["
	<< this->runSaveWeights << "]\n";
	return;
}

CppClpPrimalColumnPivotBase::CppClpPrimalColumnPivotBase(PyObject *obj, runPivotColumn_t runPivotColumn,
													   runClone_t runClone, runSaveWeights_t runSaveWeights) :
  obj(obj),
  runPivotColumn(runPivotColumn),
	runClone(runClone),
	runSaveWeights(runSaveWeights)
{
}

CppClpPrimalColumnPivotBase::~CppClpPrimalColumnPivotBase()
{
}

void CppClpPrimalColumnPivotBase::setModel(IClpSimplex* m)
{
	ClpSimplex* s = static_cast<ClpSimplex*>(m);
	model_ = s;
}

IClpSimplex* CppClpPrimalColumnPivotBase::model()
{
	return static_cast<IClpSimplex*> (model_);
}



================================================
FILE: cylp/cpp/IClpPrimalColumnPivotBase.h
================================================
#include "Python.h"
#include <iostream>
using namespace std;

#include "ClpPrimalColumnPivot.hpp"
#include "CoinIndexedVector.hpp"
#include "IClpSimplex.hpp"
//#include "ClpSimplex.hpp"
#include "ClpFactorization.hpp"

typedef int (*runPivotColumn_t)(void *instance, CoinIndexedVector*,CoinIndexedVector*
					  ,CoinIndexedVector*,CoinIndexedVector*,CoinIndexedVector*);

typedef ClpPrimalColumnPivot* (*runClone_t)(void *instance, bool copyData);

typedef void (*runSaveWeights_t)(void *instance, IClpSimplex * model,int mode);



class CppClpPrimalColumnPivotBase : public ClpPrimalColumnPivot
{
public:
  	PyObject *obj;
  	runPivotColumn_t runPivotColumn;
	runClone_t runClone;
	runSaveWeights_t runSaveWeights;

	//IClpSimplex model_;

  	CppClpPrimalColumnPivotBase(PyObject *obj, runPivotColumn_t ,
							 runClone_t , runSaveWeights_t );
  	virtual ~CppClpPrimalColumnPivotBase();

	virtual ClpPrimalColumnPivot * clone(bool copyData = true) const;
	//virtual void saveWeights(IClpSimplex * model,int mode);
  	virtual void saveWeights(ClpSimplex * model,int mode);
  	virtual int pivotColumn(CoinIndexedVector * updates,
			  CoinIndexedVector * spareRow1,
			  CoinIndexedVector * spareRow2,
			  CoinIndexedVector * spareColumn1,
						  CoinIndexedVector * spareColumn2);
	void setModel(IClpSimplex* m);
	IClpSimplex* model();

};




================================================
FILE: cylp/cpp/IClpSimplex.cpp
================================================
#include "IClpSimplex.hpp"

#include "ClpSimplexDual.hpp"
//#include "IClpSimplexPrimal.hpp"
#include "IClpSimplexPrimal.hpp"
#include "ClpSimplexPrimal.hpp"
#include "IClpPackedMatrix.hpp"
#include "OsiClpSolverInterface.hpp"
#include <sstream>
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <numpy/ndarraytypes.h>

int IClpSimplex::argWeightedMax(PyObject* arr, PyObject* arr_ind, PyObject* w, PyObject* w_ind){
    //_import_array();

    npy_intp w_ind_len = PyArray_DIM(reinterpret_cast<PyArrayObject*>(w_ind), 0);
    if (w_ind_len == 0)
        return -1; //return PyArray_ArgMax(reinterpret_cast<PyArrayObject*>(arr));

    int wIsNum = false;
    int wholeArray = false;

    double w_num_val;
    if (PyLong_Check(w)){
        wIsNum = true;
        w_num_val = PyLong_AsDouble(w);
    }else if (PyFloat_Check(w)){
        wIsNum = true;
        w_num_val = PyFloat_AsDouble(w);
    }else if (!PyArray_Check(w)){
        PyErr_SetString(PyExc_ValueError,
                "weights should be a number or a numpy array.");
        return -1;
    }


    if (PyLong_Check(arr_ind) || PyFloat_Check(arr_ind)){
        wholeArray = true;
    }else if (!PyArray_Check(arr_ind)){
        PyErr_SetString(PyExc_ValueError,
                "arr_ind should be a number(meaning 1..len(arr) or a numpy array.");
        return -1;
    }
    if (!PyArray_Check(arr) || !PyArray_Check(w_ind)){
        PyErr_SetString(PyExc_ValueError,
                "arr and w_ind should be numpy arrays.");
        return -1;
    }


    PyObject* arr_it = PyArray_IterNew(arr);

    npy_intp arr_len = PyArray_DIM(reinterpret_cast<PyArrayObject*>(arr), 0);

    if (arr_len == 0)
        return 0;


    double maxVal;// = *(double*)PyArray_ITER_DATA(arr_it);
    int maxInd;// = 0;
    double curVal;
    double curInd;
    //int w_ind_val;
    //double w_val;



    //consider 4 cases:
    //1- whole array, weight is a single number
    //2- whole array, weights array
    //3- arr_ind, weights number
    //4- arr_ind, weights array
    if (wholeArray){
        maxVal = *(double*)PyArray_ITER_DATA(arr_it);
        maxInd = 0;
        PyObject* w_ind_it= PyArray_IterNew(w_ind);
        int w_ind_val = *(int*)PyArray_ITER_DATA(w_ind_it);

        if (wIsNum){
            if (w_ind_val == 0){
                maxVal *= w_num_val;
                PyArray_ITER_NEXT(w_ind_it);
                w_ind_val = *(int*)PyArray_ITER_DATA(w_ind_it);
            }
            PyArray_ITER_NEXT(arr_it);

            for (int i = 1 ; i < arr_len ; i++){
                curVal = *(double*)PyArray_ITER_DATA(arr_it);
                if (w_ind_val == i){
                    curVal *= w_num_val;
                    PyArray_ITER_NEXT(w_ind_it);
                    w_ind_val = *(int*)PyArray_ITER_DATA(w_ind_it);
                }
                if (curVal > maxVal){
                    maxVal = curVal;
                    maxInd = i;
                }

                PyArray_ITER_NEXT(arr_it);
            }
        }
        else{ //look in whole array, weights array
            npy_intp w_len = PyArray_DIM(reinterpret_cast<PyArrayObject*>(w), 0);
            npy_intp w_ind_len = PyArray_DIM(reinterpret_cast<PyArrayObject*>(w_ind), 0);
            if (w_ind_len != w_len){
                PyErr_SetString(PyExc_ValueError,
                        "If w is a numpy array, w_ind should be a numpy array of the same size.");
                return -1;
            }

            PyObject* w_it= PyArray_IterNew(w);
            double w_val = *(double*)PyArray_ITER_DATA(w_it);
            if (w_ind_val == 0){
                maxVal *= w_val; //*(double *)PyArray_GETITEM(w, PyArray_GETPTR1(w, 0));
                PyArray_ITER_NEXT(w_ind_it);
                PyArray_ITER_NEXT(w_it);
                w_ind_val = *(int*)PyArray_ITER_DATA(w_ind_it);
                w_val = *(double*)PyArray_ITER_DATA(w_it);
            }

            PyArray_ITER_NEXT(arr_it);

            for (int i = 1 ; i < arr_len ; i++){
                curVal = *(double*)PyArray_ITER_DATA(arr_it);
                if (w_ind_val == i){
                    curVal *= w_val;//*(double*)PyArray_GETITEM(w, PyArray_GETPTR1(w, i));
                    PyArray_ITER_NEXT(w_ind_it);
                    PyArray_ITER_NEXT(w_it);
                    w_ind_val = *(int*)PyArray_ITER_DATA(w_ind_it);
                    w_val = *(double*)PyArray_ITER_DATA(w_it);
                }
                if (curVal > maxVal){
                    maxVal = curVal;
                    maxInd = i;
                }

                PyArray_ITER_NEXT(arr_it);
            }

        }
    }
    else{  //only indices specified in arr_ind

        npy_intp arr_ind_len = PyArray_DIM(reinterpret_cast<PyArrayObject*>(arr_ind), 0);
        npy_intp arr_len = PyArray_DIM(reinterpret_cast<PyArrayObject*>(arr), 0);

        if (arr_ind_len != arr_len){
            PyErr_SetString(PyExc_ValueError,
                    "If a_ind is a numpy array, arr should be a numpy array of the same size.");
            return -1;
        }

        PyObject* arr_ind_it = PyArray_IterNew(arr_ind);
        int arr_ind_val = *(int*)PyArray_ITER_DATA(arr_ind_it);
        PyObject* arr_it = PyArray_IterNew(arr);
        double arr_val = *(double*)PyArray_ITER_DATA(arr_it);


        maxVal = arr_val;
        maxInd = 0 ; //arr_ind_val;
        //std::cout << "maxVal = " << maxVal << "\n";
        //std::cout << "maxInd = " << maxInd << "\n";


        if (wIsNum){
            PyObject* w_ind_it = PyArray_IterNew(w_ind);
            int w_ind_val = *(int*)PyArray_ITER_DATA(w_ind_it);
            while (PyArray_ITER_NOTDONE(w_ind_it) && arr_ind_val > w_ind_val){
                PyArray_ITER_NEXT(w_ind_it);
                w_ind_val = *(int*)PyArray_ITER_DATA(w_ind_it);
            }
            if (arr_ind_val == w_ind_val){
                maxVal *= w_num_val;
                PyArray_ITER_NEXT(w_ind_it);
                w_ind_val = *(int*)PyArray_ITER_DATA(w_ind_it);
            }

            for (int i = 1 ; i < arr_ind_len ; i++){
                PyArray_ITER_NEXT(arr_ind_it);
                PyArray_ITER_NEXT(arr_it);

                arr_ind_val = *(int*)PyArray_ITER_DATA(arr_ind_it);
                arr_val = *(double*)PyArray_ITER_DATA(arr_it); //*(double*)PyArray_GETITEM(arr, PyArray_GETPTR1(arr, arr_ind_val));

                while (PyArray_ITER_NOTDONE(w_ind_it) && arr_ind_val > w_ind_val){
                    PyArray_ITER_NEXT(w_ind_it);
                    w_ind_val = *(int*)PyArray_ITER_DATA(w_ind_it);
                }

                if (arr_ind_val == w_ind_val)
                    arr_val *= w_num_val;
                if (arr_val > maxVal){
                    maxVal = arr_val;
                    maxInd = i;
                }


            }
        }
        else{  //just elements specified in arr_ind, weight's an array

            npy_intp arr_ind_len = PyArray_DIM(reinterpret_cast<PyArrayObject*>(arr_ind), 0);
            npy_intp arr_len = PyArray_DIM(reinterpret_cast<PyArrayObject*>(arr), 0);

            if (arr_ind_len != arr_len){
                PyErr_SetString(PyExc_ValueError,
                        "If a_ind is a numpy array, arr should be a numpy array of the same size.");
                return -1;
            }


            npy_intp w_len = PyArray_DIM(reinterpret_cast<PyArrayObject*>(w), 0);
            npy_intp w_ind_len = PyArray_DIM(reinterpret_cast<PyArrayObject*>(w_ind), 0);
            if (w_ind_len != w_len){
                PyErr_SetString(PyExc_ValueError,
                        "If w is a numpy array, w_ind should be a numpy array of the same size.");
                return -1;
            }

            PyObject* w_ind_it = PyArray_IterNew(w_ind);
            int w_ind_val = *(int*)PyArray_ITER_DATA(w_ind_it);
            PyObject* w_it = PyArray_IterNew(w);
            double w_val = *(double*)PyArray_ITER_DATA(w_it);


            while (PyArray_ITER_NOTDONE(w_ind_it) && arr_ind_val > w_ind_val){
                PyArray_ITER_NEXT(w_ind_it);
                PyArray_ITER_NEXT(w_it);
                w_ind_val = *(int*)PyArray_ITER_DATA(w_ind_it);
                w_val = *(double*)PyArray_ITER_DATA(w_it);
            }

            if (arr_ind_val == w_ind_val){
                maxVal *= w_val;
                PyArray_ITER_NEXT(w_ind_it);
                PyArray_ITER_NEXT(w_it);
                w_ind_val = *(int*)PyArray_ITER_DATA(w_ind_it);
                w_val = *(double*)PyArray_ITER_DATA(w_it);

            }

            for (int i = 1 ; i < arr_ind_len ; i++){
                PyArray_ITER_NEXT(arr_ind_it);
                PyArray_ITER_NEXT(arr_it);

                arr_ind_val = *(int*)PyArray_ITER_DATA(arr_ind_it);
                arr_val = *(double*)PyArray_ITER_DATA(arr_it); //*(double*)PyArray_GETITEM(arr, PyArray_GETPTR1(arr, arr_ind_val));

                while (PyArray_ITER_NOTDONE(w_ind_it) && arr_ind_val > w_ind_val){
                    PyArray_ITER_NEXT(w_ind_it);
                    PyArray_ITER_NEXT(w_it);
                    w_ind_val = *(int*)PyArray_ITER_DATA(w_ind_it);
                    w_val = *(double*)PyArray_ITER_DATA(w_it);
                }

                if (arr_ind_val == w_ind_val){
                    arr_val *= w_val;
                    PyArray_ITER_NEXT(w_ind_it);
                    PyArray_ITER_NEXT(w_it);
                    w_ind_val = *(int*)PyArray_ITER_DATA(w_ind_it);
                    w_val = *(double*)PyArray_ITER_DATA(w_it);

                }
                if (arr_val > maxVal){
                    maxVal = arr_val;
                    maxInd = i;
                }


            }
        }
    }
    return maxInd;
}


int IClpSimplex::argWeightedMax(PyObject* arr, PyObject* whr, double weight){
    //_import_array();
    if (!PyArray_Check(arr) || !PyArray_Check(whr)){
        PyErr_SetString(PyExc_ValueError,
                "Arguments of argWeightedMax should be numpy arrays.");
        return -1;
    }
    PyObject* arr_it = PyArray_IterNew(arr);
    PyObject* whr_it = PyArray_IterNew(whr);

    npy_intp arr_len = PyArray_DIM(reinterpret_cast<PyArrayObject*>(arr), 0);

    if (arr_len == 0)
        return 0;

    double maxVal = *(double*)PyArray_ITER_DATA(arr_it);
    int maxInd = 0;
    double curVal;
    double curInd;

    int curWhere = *(int*)PyArray_ITER_DATA(whr_it);
    if (curWhere == 0){
        maxVal *= weight;
        PyArray_ITER_NEXT(whr_it);
        curWhere = *(int*)PyArray_ITER_DATA(whr_it);
    }

    PyArray_ITER_NEXT(arr_it);

    for (int i = 1 ; i < arr_len ; i++){
        curVal = *(double*)PyArray_ITER_DATA(arr_it);
        if (curWhere == i){
            curVal *= weight;
            PyArray_ITER_NEXT(whr_it);
            curWhere = *(int*)PyArray_ITER_DATA(whr_it);
        }
        if (curVal > maxVal){
            maxVal = curVal;
            maxInd = i;
        }

        PyArray_ITER_NEXT(arr_it);
    }
    return maxInd;
}

bool IClpSimplex::varIsFree(int ind){
    return getStatus(ind) == ClpSimplex::isFree;
}

bool IClpSimplex::varBasic(int ind){
    return getStatus(ind) == ClpSimplex::basic;
}

bool IClpSimplex::varAtUpperBound(int ind){
    return getStatus(ind) == ClpSimplex::atUpperBound;
}

bool IClpSimplex::varAtLowerBound(int ind){
    return getStatus(ind) == ClpSimplex::atLowerBound;
}

bool IClpSimplex::varSuperBasic(int ind){
    return getStatus(ind) == ClpSimplex::superBasic;
}


bool IClpSimplex::varIsFixed(int ind){
    return getStatus(ind) == ClpSimplex::isFixed;
}
PyObject* IClpSimplex::getStatusArray(){

    npy_intp dims = getNumCols() + getNumRows();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_UINT8, this->status_ );

    return Arr;
}


PyObject* IClpSimplex::getReducedCosts(){

    npy_intp dims = getNumCols() + getNumRows();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->djRegion() );

    return Arr;
}

void IClpSimplex::setReducedCosts(double* rc){
    int dim = getNumCols() + getNumRows();
    for (int i = 0; i < dim; i++) {
        dj_[i] = rc[i];
    }
}


PyObject* IClpSimplex::getComplementarityList(){

    npy_intp dims = getNumCols() + getNumRows();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT32, QP_ComplementarityList );

    return Arr;
}

PyObject* IClpSimplex::getPivotVariable(){

    npy_intp dims = getNumRows();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT32, this->pivotVariable() );

    return Arr;
}


PyObject* IClpSimplex::getPrimalRowSolution(){

    npy_intp dims = getNumRows();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->primalRowSolution() );

    return Arr;
}

PyObject* IClpSimplex::getPrimalColumnSolution(){

    npy_intp dims = getNumCols();
    PyObject *Arr = PyArray_SimpleNewFromData(1, &dims, NPY_DOUBLE, this->primalColumnSolution() );

    return Arr;
}

PyObject* IClpSimplex::getPrimalColumnSolutionAll(){
    npy_intp dims = getNumCols() + getNumRows();
    PyObject *Arr = PyArray_SimpleNewFromData(1, &dims, NPY_DOUBLE, this->primalColumnSolution() );
    return Arr;
}

PyObject* IClpSimplex::getSolutionRegion(){
    npy_intp dims = getNumCols() + getNumRows();
    PyObject *Arr = PyArray_SimpleNewFromData(1, &dims, NPY_DOUBLE, this->solutionRegion() );
    return Arr;
}

PyObject* IClpSimplex::getCostRegion(){
    npy_intp dims = getNumCols() + getNumRows();
    PyObject *Arr = PyArray_SimpleNewFromData(1, &dims, NPY_DOUBLE, this->costRegion() );
    return Arr;
}

PyObject* IClpSimplex::getDualRowSolution(){

    npy_intp dims = getNumRows();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->dualRowSolution() );

    return Arr;
}

PyObject* IClpSimplex::getDualColumnSolution(){

    npy_intp dims = getNumCols();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->dualColumnSolution() );

    return Arr;
}

PyObject* IClpSimplex::getObjective(){

    npy_intp dims = getNumCols();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->objective() );
    return Arr;
}

PyObject* IClpSimplex::getRowLower(){

    npy_intp dims = getNumRows();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->rowLower() );
    return Arr;
}

PyObject* IClpSimplex::getRowUpper(){

    npy_intp dims = getNumRows();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->rowUpper() );
    return Arr;
}

PyObject* IClpSimplex::getUpper(){

    npy_intp dims = getNumRows() + getNumCols();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->upperRegion() );
    return Arr;
}

PyObject* IClpSimplex::getLower(){

    npy_intp dims = getNumRows() + getNumCols();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->lowerRegion() );
    return Arr;
}

PyObject* IClpSimplex::getColLower(){

    npy_intp dims = getNumCols();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->columnLower() );
    return Arr;
}

PyObject* IClpSimplex::getColUpper(){

    npy_intp dims = getNumCols();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, this->columnUpper() );
    return Arr;
}

PyObject* IClpSimplex::getColumnScale(){

    npy_intp dims = getNumCols();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE,  columnScale_);
    return Arr;
}

PyObject* IClpSimplex::getRowScale(){

    npy_intp dims = getNumRows();
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_DOUBLE, rowScale_ );
    return Arr;
}



PyObject* IClpSimplex::getIntegerInformation(){
    npy_intp dims = getNumCols();
    PyObject* Arr;
    if (this->integerInformation())
        Arr = PyArray_SimpleNewFromData(1, &dims, NPY_INT8, this->integerInformation());
    else
        Arr = PyArray_ZEROS(1, &dims, NPY_INT8, 0);
    return Arr;
}

std::vector<std::string> IClpSimplex::getVariableNames(){
    if (lengthNames_)
        return columnNames_;
    return std::vector<std::string> ();
}

void IClpSimplex::setVariableName(int varInd,  char* name){
    if (varInd >= getNumCols())
        return;
    if (lengthNames_ == 0){
        unsigned int maxLength=0;
        int iRow;

        rowNames_ = std::vector<std::string> ();
        columnNames_ = std::vector<std::string> ();
        rowNames_.reserve(numberRows_);
        for (iRow=0;iRow<numberRows_;iRow++) {
            std::stringstream ss;
            ss << "r-";
            ss << iRow;
            std::string rowName = ss.str();
            if (rowName.length() > maxLength)
                maxLength = rowName.length();
            rowNames_.push_back(rowName);
        }

        columnNames_.reserve(numberColumns_);
        int iColumn;
        for (iColumn=0;iColumn<numberColumns_;iColumn++) {
            std::stringstream ss;
            ss << "c-";
            ss << iColumn;
            std::string colName = ss.str();
            if (colName.length() > maxLength)
                maxLength = colName.length();
            columnNames_.push_back(colName);
        }
//
//        int iColumn;
//        columnNames_.reserve(numberColumns_);
//        for (iColumn=0;iColumn<numberColumns_;iColumn++) {
//            const char * name = m.columnName(iColumn);
//            maxLength = std::max(maxLength,static_cast<unsigned int> (strlen(name)));
//            columnNames_.push_back(name);
//        }
        lengthNames_=static_cast<int> (maxLength);
//    columnNames_.resize(getNumCols());

    //std::cout << columnNamesAsChar()[10] << "<$$$$$$$$$$$$$\n";
    }
    std::string st(name);
    columnNames_[varInd] = st;
}

void IClpSimplex::setConstraintName(int constInd,  char* name){
    if (constInd >= getNumRows())
        return;
    if (lengthNames_ == 0){
        unsigned int maxLength=0;
        int iRow;

        rowNames_ = std::vector<std::string> ();
        columnNames_ = std::vector<std::string> ();
        rowNames_.reserve(numberRows_);
        for (iRow=0;iRow<numberRows_;iRow++) {
            std::stringstream ss;
            ss << "r-";
            ss << iRow;
            std::string rowName = ss.str();
            if (rowName.length() > maxLength)
                maxLength = rowName.length();
            rowNames_.push_back(rowName);
        }

        columnNames_.reserve(numberColumns_);
        int iColumn;
        for (iColumn=0;iColumn<numberColumns_;iColumn++) {
            std::stringstream ss;
            ss << "c-";
            ss << iColumn;
            std::string colName = ss.str();
            if (colName.length() > maxLength)
                maxLength = colName.length();
            columnNames_.push_back(colName);
        }
        lengthNames_=static_cast<int> (maxLength);
    }
    std::string st(name);
    rowNames_[constInd] = st;
}

void IClpSimplex::createTempArray(){
    tempIntArray = new int[getNumCols() + getNumRows()];
    tempArrayExists = true;
}

IClpSimplex::IClpSimplex(PyObject *obj_arg, runIsPivotAcceptable_t runIsPivotAcceptable_arg,
                         varSelCriteria_t runVarSelCriteria ):ClpSimplex()
                        {

    _import_array();
    tempArrayExists = false;
    obj = obj_arg;
    runIsPivotAcceptable = runIsPivotAcceptable_arg;
    varSelCriteria = runVarSelCriteria;
    customPrimal = 0;
    createStatus();
    pinfo = ClpPresolve();

    tempRow = NULL;
    tempRow_vector = NULL;
    QP_BanList = NULL;
    QP_ComplementarityList = NULL;
}




void IClpSimplex::useCustomPrimal(int u)
{
    customPrimal = u;
}

int IClpSimplex::getUseCustomPrimal()
{
    return customPrimal;
}

void IClpSimplex::setComplementarityList(int * cl)
{
    QP_ComplementarityList = cl;
}

int* IClpSimplex::ComplementarityList()
{
    return QP_ComplementarityList;
}

void IClpSimplex::setBasisStatus(const int* cstat, const int* rstat){
    OsiClpSolverInterface osi(this, false);
    osi.setBasisStatus(cstat, rstat);
    return;
}

void IClpSimplex::setMaxNumIteration(int m){
    setIntParam(ClpMaxNumIteration, m);
}

void IClpSimplex::getBasisStatus(int* cstat, int* rstat){
    OsiClpSolverInterface osi(this, false);
    osi.getBasisStatus(cstat, rstat);
    return;
}

IClpSimplex::IClpSimplex (ClpSimplex * wholeModel,
        int numberColumns, const int * whichColumns):
    ClpSimplex(wholeModel, numberColumns, whichColumns)
{
    _import_array();
    tempArrayExists = false;
    tempRow_vector = NULL;
    tempRow = NULL;

    QP_ComplementarityList = NULL;
    QP_BanList = NULL;//new int[nvars];
    pinfo = ClpPresolve();
}


IClpSimplex::~IClpSimplex(){
    if (QP_ComplementarityList)
        delete QP_ComplementarityList;

    if (QP_BanList)
        delete QP_BanList;

    if (tempRow)
        delete tempRow;

    if (tempRow_vector)
        delete tempRow_vector;

}


void IClpSimplex::dualExpanded(ClpSimplex * model,CoinIndexedVector * array,
        double * other,int mode){

    this->clpMatrix()->dualExpanded(model,array,other,mode);
}

int IClpSimplex::isPivotAcceptable()
{
    if (this->obj && this->runIsPivotAcceptable) {
        return this->runIsPivotAcceptable(this->obj);
    }
    std::cerr << "** pivotRow: invalid cy-state: obj [" << this->obj << "] fct: ["
        << this->runIsPivotAcceptable << "]\n";
    return -1;
}

void IClpSimplex::setCriteria(varSelCriteria_t vsc){
    varSelCriteria = vsc;
}

int IClpSimplex::checkVar(int varInd){
    if (this->obj && this->varSelCriteria) {
        return this->varSelCriteria(this->obj, varInd);
    }
    std::cerr << "** pivotRow: invalid cy-state: obj [" << this->obj << "] fct: ["
        << this->varSelCriteria << "]\n";
    return -1;

}


ICbcModel* IClpSimplex::getICbcModel(){
    // ?
    matrix_->setDimensions(numberRows_, numberColumns_);

    OsiClpSolverInterface solver1(this);
    ICbcModel*  model = new ICbcModel(solver1);
    return model;
}

void  IClpSimplex::writeLp(const char *filename,
                       const char *extension,
                       double epsilon,
                       int numberAcross,
                       int decimals,
                       double objSense,
                       bool useRowNames)
    {
    matrix_->setDimensions(numberRows_, numberColumns_);

    OsiClpSolverInterface solver1(this);
    solver1.writeLp(filename, extension, epsilon, numberAcross, decimals, objSense, useRowNames);
    return ;

    }



//Get a column of the tableau
    void
IClpSimplex::getBInvACol(int col, double* vec)
{
    if (!rowArray_[0]) {
        printf("ClpSimplexPrimal or ClpSimplexDual should have been called with correct startFinishOption\n");
        abort();
    }
    CoinIndexedVector * rowArray0 = rowArray(0);
    CoinIndexedVector * rowArray1 = rowArray(1);
    rowArray0->clear();
    rowArray1->clear();
    // get column of matrix
#ifndef NDEBUG
    int n = numberColumns_+numberRows_;
    if (col<0||col>=n) {
        //indexError(col,"getBInvACol");
    }
#endif
    if (!rowScale_) {
        if (col<numberColumns_) {
            unpack(rowArray1,col);
        } else {
            rowArray1->insert(col-numberColumns_,1.0);
        }
    } else {
        if (col<numberColumns_) {
            unpack(rowArray1,col);
            double multiplier = 1.0*inverseColumnScale_[col];
            int number = rowArray1->getNumElements();
            int * index = rowArray1->getIndices();
            double * array = rowArray1->denseVector();
            for (int i=0;i<number;i++) {
                int iRow = index[i];
                // make sure not packed
                assert (array[iRow]);
                array[iRow] *= multiplier;
            }
        } else {
            rowArray1->insert(col-numberColumns_,rowScale_[col-numberColumns_]);
        }
    }
    factorization_->updateColumn(rowArray0,rowArray1,false);
    // But swap if pivot variable was slack as clp stores slack as -1.0
    double * array = rowArray1->denseVector();
    if (!rowScale_) {
        for (int i=0;i<numberRows_;i++) {
            double multiplier = (pivotVariable_[i]<numberColumns_) ? 1.0 : -1.0;
            vec[i] = multiplier * array[i];
        }
    } else {
        for (int i=0;i<numberRows_;i++) {
            int pivot = pivotVariable_[i];
            if (pivot<numberColumns_)
                vec[i] = array[i] * columnScale_[pivot];
            else
                vec[i] = - array[i] / rowScale_[pivot-numberColumns_];
        }
    }
    rowArray1->clear();
}


//Fetches the ncol th column into colArray
void IClpSimplex::getACol(int ncol, CoinIndexedVector * colArray){


    //CoinIndexedVector * colArray = temp_rowArray[1];

    colArray->clear();

    // get column of matrix
#ifndef NDEBUG
    //int n = numberColumns_+numberRows_;
    //if (ncol<0||ncol>=n) {
    //	indexError(ncol,"getBInvACol");
    //}
#endif

    if (!rowScale()) {
        if (ncol<numberColumns()) {
            unpack(colArray,ncol);
        } else {
            colArray->insert(ncol- numberColumns(),1.0);
        }
    } else {
        if (ncol<numberColumns()) {
            unpack(colArray,ncol);
            double multiplier = 1.0* inverseColumnScale()[ncol];
            int number = colArray->getNumElements();
            int * index = colArray->getIndices();
            double * array = colArray->denseVector();
            for (int i=0;i<number;i++) {
                int iRow = index[i];
                // make sure not packed
                assert (array[iRow]);
                array[iRow] *= multiplier;
            }
        } else {
            colArray->insert(ncol- numberColumns(),rowScale()[ncol-numberColumns()]);
        }
    }

}


void IClpSimplex::getRightHandSide(double* righthandside)
{
    int nr=numberRows();

    extractSenseRhsRange(righthandside);

    int* basis_index = pivotVariable();


    //FIXME: change these lines to be like getColSoution and getRowActivity in OsiClp
    const double *solution = solutionRegion(1);
    const double *row_act = solutionRegion(0);

    //FIXME: This must be fixed. The first line causes seg fault
    //So I'm allocating and deleting in this function
    //double *slack_val = tempRow;
    double *slack_val = new double[nr];

    for(int i=0; i<nr; i++) {
        slack_val[i] = righthandside[i] - row_act[i];
    }

    int ncol = numberColumns();
    for (int i = 0 ; i < nr; i++) {
        if (basis_index[i] < ncol){
            righthandside[i] = solution[basis_index[i]];
            //std::cout << "sim: rhs " << i << " = " << solution[basis_index[i]] << "\n";
        }else {
            righthandside[i] = slack_val[basis_index[i]-ncol];
            //std::cout << "sim: rhs " << i << " = " << slack_val[basis_index[i]-ncol] << "\n";
        }

    }

    delete slack_val;

    //return righthandside;
}


void IClpSimplex::extractSenseRhsRange(double* rhs_)
{
    //if (rowsense_ == NULL) {
    // all three must be NULL
    //assert ((rhs_ == NULL) && (rowrange_ == NULL));

    int nr=numberRows();
    if ( nr!=0 ) {
        //char* rowsense_ = new char[nr];
        //double* rhs_ = new double[nr];
        //double* rowrange_ = PE_tempRow[0]; //new double[nr];
        //std::fill(rowrange_,rowrange_+nr,0.0);

        const double * lb = rowLower();
        const double * ub = rowUpper();

        int i;
        for ( i=0; i<nr; i++ ) {
            //std::cout << i << " : " << lb[i] << ", " << ub[i] << "\n";
            //convertBoundToSense(lb[i], ub[i], rowsense_[i], rhs_[i], rowrange_[i]);
            convertBoundToSense(lb[i], ub[i], rhs_[i]);
        }

        //delete rowrange_;
        //delete rowsense_;
    }

}

void IClpSimplex::convertBoundToSense(const double lower, const double upper,
        double& right)
{
   double inf = pow(double(10), 16);
    if (lower > -inf) {
        if (upper < inf) {
            right = upper;
            //if (upper==lower) {
            //sense = 'E';
            //} else {
            //sense = 'R';
            //range = upper - lower;
            //}
        } else {
            //sense = 'G';
            right = lower;
        }
    } else {
        if (upper < inf) {
            //sense = 'L';
            right = upper;
        } else {
            //sense = 'N';
            right = 0.0;
        }
    }
}


void IClpSimplex::vectorTimesB_1(CoinIndexedVector* vec){
    factorization_->updateColumnTranspose(tempRow_vector, vec);
}



void IClpSimplex::transposeTimesSubset(int number, int* which, double* pi, double* y){
    reinterpret_cast<IClpPackedMatrix*>(matrix_)->transposeTimesSubset(number,
                             which, pi, y, rowScale(), columnScale(), NULL);
}


void IClpSimplex::transposeTimes(const ClpSimplex * model, double scalar,
                                 const CoinIndexedVector * x,
                                 CoinIndexedVector * y,
                                 CoinIndexedVector * z){
    reinterpret_cast<IClpPackedMatrix*>(matrix_)->transposeTimes(
                                model, scalar, x, y, z);
}


void IClpSimplex::transposeTimesSubsetAll(int number, long long int* which, double* pi, double* y){
    reinterpret_cast<IClpPackedMatrix*>(matrix_)->transposeTimesSubsetAll(this, number,
                             which, pi, y, rowScale(), columnScale(), NULL);
}

// Copy constructor.
IClpSimplex::IClpSimplex(const ClpSimplex &rhs,PyObject *obj,
                            runIsPivotAcceptable_t runIsPivotAcceptable,
                            varSelCriteria_t varSelCriteria,
                            int useCustomPrimal, int scalingMode ) :
  ClpSimplex(rhs,scalingMode),
    obj(obj),
    runIsPivotAcceptable(runIsPivotAcceptable),
    varSelCriteria(varSelCriteria),
    customPrimal(useCustomPrimal),
    tempArrayExists(false),
    tempRow(NULL),
    tempRow_vector(NULL),
    QP_BanList(NULL),
    QP_ComplementarityList(NULL)
{
}




IClpSimplex* IClpSimplex::preSolve(IClpSimplex* si,
        double feasibilityTolerance,
        bool keepIntegers,
        int numberPasses,
        bool dropNames,
        bool doRowObjective)
{
    //ClpPresolve pinfo;
    ClpSimplex* s = pinfo.presolvedModel(*si,feasibilityTolerance,
                            keepIntegers, numberPasses, dropNames, doRowObjective);
    if (s)
        {
        IClpSimplex* ret = new IClpSimplex(*s, si->obj, si->runIsPivotAcceptable, si->varSelCriteria, si->customPrimal);
        //ret->pinfo = pinfo;
        //pinfo.postsolve();
        return ret;
        }

    return NULL;
}

void IClpSimplex::postSolve(bool updateStatus){
    pinfo.postsolve(updateStatus);
}


int IClpSimplex::dualWithPresolve(IClpSimplex* si,
        double feasibilityTolerance,
        bool keepIntegers,
        int numberPasses,
        bool dropNames,
        bool doRowObjective)
{
    ClpPresolve pinfoTemp;
    ClpSimplex* s = pinfoTemp.presolvedModel(*si,feasibilityTolerance,
                            keepIntegers, numberPasses, dropNames, doRowObjective);
    if (s)
        {
        int ret = s->dual();
        pinfoTemp.postsolve();
        delete s;
        checkSolution();
        dual();
        return ret;
        }
    return -2000;
}


int IClpSimplex::primalWithPresolve(IClpSimplex* si,
        double feasibilityTolerance,
        bool keepIntegers,
        int numberPasses,
        bool dropNames,
        bool doRowObjective)
{
    ClpPresolve pinfoTemp;
    ClpSimplex* s = pinfoTemp.presolvedModel(*si,feasibilityTolerance,
                            keepIntegers, numberPasses, dropNames, doRowObjective);
    if (s)
        {
        int ret = s->primal();
        pinfoTemp.postsolve();
        delete s;
        checkSolution();
        primal();
        return ret;
        }
    return -2000;
}

int IClpSimplex::initialSolve(int preSolveType){
    ClpSolve options;
    options.setPresolveType(static_cast<ClpSolve::PresolveType>(preSolveType));
    return ClpSimplex::initialSolve(options);
}


int IClpSimplex::primal (int ifValuesPass , int startFinishOptions)
{
    // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    if (tempRow == NULL)
        tempRow = new double[numberRows()];
    if (tempRow_vector == NULL)
        tempRow_vector = new CoinIndexedVector();
    if (QP_BanList == NULL)
        QP_BanList = new int[numberColumns() + numberRows()];
    //FIXME: This is a crazy 1000 here.
    //But whatever you do to fix this try it on adlittle, degen2
    tempRow_vector->reserve(numberRows() + numberColumns() + numberExtraRows() + 1000);
    //tempRow_vector->reserve(numberRows() + +numberColumns() + numberExtraRows());


    //double savedPivotTolerance = factorization_->pivotTolerance();
#ifndef SLIM_CLP
    // See if nonlinear
    if (objective_->type()>1&&objective_->activated())
        return reducedGradient();
#endif
    CoinAssert ((ifValuesPass>=0&&ifValuesPass<3)||
            (ifValuesPass>=12&&ifValuesPass<100)||
            (ifValuesPass>=112&&ifValuesPass<200));
    if (ifValuesPass>=12) {
        int numberProblems = (ifValuesPass-10)%100;
        ifValuesPass = (ifValuesPass<100) ? 1 : 2;
        // Go parallel to do solve
        // Only if all slack basis
        int i;
        for ( i=0;i<numberColumns_;i++) {
            if (getColumnStatus(i)==basic)
                break;
        }
        if (i==numberColumns_) {
            // try if vaguely feasible
            CoinZeroN(ClpModel::rowActivity_,numberRows_);
            const int * row = matrix_->getIndices();
            const CoinBigIndex * columnStart = matrix_->getVectorStarts();
            const int * columnLength = matrix_->getVectorLengths();
            const double * element = matrix_->getElements();
            for (int iColumn=0;iColumn<numberColumns_;iColumn++) {
                CoinBigIndex j;
                double value = ClpModel::columnActivity_[iColumn];
                if (value) {
                    CoinBigIndex start = columnStart[iColumn];
                    CoinBigIndex end = start + columnLength[iColumn];
                    for (j=start; j<end; j++) {
                        int iRow=row[j];
                        ClpModel::rowActivity_[iRow] += value*element[j];
                    }
                }
            }
            checkSolutionInternal();
            if (sumPrimalInfeasibilities_*sqrt(static_cast<double>(numberRows_))<1.0) {
                // Could do better if can decompose
                // correction to get feasible
                double scaleFactor = 1.0/numberProblems;
                double * correction = new double [numberRows_];
                for (int iRow=0;iRow<numberRows_;iRow++) {
                    double value=ClpModel::rowActivity_[iRow];
                    if (value>rowUpper_[iRow])
                        value = rowUpper_[iRow]-value;
                    else if (value<rowLower_[iRow])
                        value = rowLower_[iRow]-value;
                    else
                        value=0.0;
                    correction[iRow]=value*scaleFactor;
                }
                int numberColumns = (numberColumns_+numberProblems-1)/numberProblems;
                int * whichRows = new int [numberRows_];
                for (int i=0;i<numberRows_;i++)
                    whichRows[i]=i;
                int * whichColumns = new int [numberColumns_];
                ClpSimplex ** model = new ClpSimplex * [numberProblems];
                int startColumn=0;
                double * saveLower = CoinCopyOfArray(rowLower_,numberRows_);
                double * saveUpper = CoinCopyOfArray(rowUpper_,numberRows_);
                for (int i=0;i<numberProblems;i++) {
                    int endColumn = std::min(startColumn+numberColumns,numberColumns_);
                    CoinZeroN(ClpModel::rowActivity_,numberRows_);
                    for (int iColumn=startColumn;iColumn<endColumn;iColumn++) {
                        whichColumns[iColumn-startColumn]=iColumn;
                        CoinBigIndex j;
                        double value = ClpModel::columnActivity_[iColumn];
                        if (value) {
                            CoinBigIndex start = columnStart[iColumn];
                            CoinBigIndex end = start + columnLength[iColumn];
                            for (j=start; j<end; j++) {
                                int iRow=row[j];
                                ClpModel::rowActivity_[iRow] += value*element[j];
                            }
                        }
                    }
                    // adjust rhs
                    for (int iRow=0;iRow<numberRows_;iRow++) {
                        double value=ClpModel::rowActivity_[iRow]+correction[iRow];
                        if (saveUpper[iRow]<1.0e30)
                            rowUpper_[iRow]=value;
                        if (saveLower[iRow]>-1.0e30)
                            rowLower_[iRow]=value;
                    }
                    model[i] = new ClpSimplex(this,numberRows_,whichRows,
                            endColumn-startColumn,whichColumns);
                    //#define FEB_TRY
#ifdef FEB_TRY
                    model[i]->setPerturbation(perturbation_);
#endif
                    startColumn=endColumn;
                }
                memcpy(rowLower_,saveLower,numberRows_*sizeof(double));
                memcpy(rowUpper_,saveUpper,numberRows_*sizeof(double));
                delete [] saveLower;
                delete [] saveUpper;
                delete [] correction;
                // solve (in parallel)
                for (int i=0;i<numberProblems;i++) {
                    model[i]->primal(1/*ifValuesPass*/);
                }
                startColumn=0;
                int numberBasic=0;
                // use whichRows as counter
                for (int iRow=0;iRow<numberRows_;iRow++) {
                    int startValue=0;
                    if (rowUpper_[iRow]>rowLower_[iRow])
                        startValue++;
                    if (rowUpper_[iRow]>1.0e30)
                        startValue++;
                    if (rowLower_[iRow]<-1.0e30)
                        startValue++;
                    whichRows[iRow]=1000*startValue;
                }
                for (int i=0;i<numberProblems;i++) {
                    int endColumn = std::min(startColumn+numberColumns,numberColumns_);
                    ClpSimplex * simplex = model[i];
                    // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                    // this line changed from columnActivity_ to getColSolution because columnactivity in protected in ClpModel
                    const double * solution = getColSolution();
                    for (int iColumn=startColumn;iColumn<endColumn;iColumn++) {
                        ClpModel::columnActivity_[iColumn] = solution[iColumn-startColumn];
                        Status status = simplex->getColumnStatus(iColumn-startColumn);
                        setColumnStatus(iColumn,status);
                        if (status==basic)
                            numberBasic++;
                    }
                    for (int iRow=0;iRow<numberRows_;iRow++) {
                        if (simplex->getRowStatus(iRow)==basic)
                            whichRows[iRow]++;
                    }
                    delete model[i];
                    startColumn=endColumn;
                }
                delete [] model;
                for (int iRow=0;iRow<numberRows_;iRow++)
                    setRowStatus(iRow,superBasic);
                CoinZeroN(ClpModel::rowActivity_,numberRows_);
                for (int iColumn=0;iColumn<numberColumns_;iColumn++) {
                    CoinBigIndex j;
                    double value = ClpModel::columnActivity_[iColumn];
                    if (value) {
                        CoinBigIndex start = columnStart[iColumn];
                        CoinBigIndex end = start + columnLength[iColumn];
                        for (j=start; j<end; j++) {
                            int iRow=row[j];
                            ClpModel::rowActivity_[iRow] += value*element[j];
                        }
                    }
                }
                checkSolutionInternal();
                if (numberBasic<numberRows_) {
                    int * order = new int [numberRows_];
                    for (int iRow=0;iRow<numberRows_;iRow++) {
                        setRowStatus(iRow,superBasic);
                        int nTimes = whichRows[iRow]%1000;
                        if (nTimes)
                            nTimes += whichRows[iRow]/500;
                        whichRows[iRow]=-nTimes;
                        order[iRow]=iRow;
                    }
                    CoinSort_2(whichRows,whichRows+numberRows_,order);
                    int nPut = numberRows_-numberBasic;
                    for (int i=0;i<nPut;i++) {
                        int iRow = order[i];
                        setRowStatus(iRow,basic);
                    }
                    delete [] order;
                } else if (numberBasic>numberRows_) {
                    double * away = new double [numberBasic];
                    numberBasic=0;
                    for (int iColumn=0;iColumn<numberColumns_;iColumn++) {
                        if (getColumnStatus(iColumn)==basic) {
                            double value = ClpModel::columnActivity_[iColumn];
                            value = std::min(value-columnLower_[iColumn],
                                    columnUpper_[iColumn]-value);
                            away[numberBasic]=value;
                            whichColumns[numberBasic++]=iColumn;
                        }
                    }
                    CoinSort_2(away,away+numberBasic,whichColumns);
                    int nPut = numberBasic-numberRows_;
                    for (int i=0;i<nPut;i++) {
                        int iColumn = whichColumns[i];
                        double value = ClpModel::columnActivity_[iColumn];
                        if (value-columnLower_[iColumn]<
                                columnUpper_[iColumn]-value)
                            setColumnStatus(iColumn,atLowerBound);
                        else
                            setColumnStatus(iColumn,atUpperBound);
                    }
                    delete [] away;
                }
                delete [] whichColumns;
                delete [] whichRows;
            }
        }
    }
    /*  Note use of "down casting".  The only class the user sees is ClpSimplex.
        Classes ClpSimplexDual, ClpSimplexPrimal, (ClpSimplexNonlinear)
        and ClpSimplexOther all exist and inherit from ClpSimplex but have no
        additional data and have no destructor or (non-default) constructor.

        This is to stop classes becoming too unwieldy and so I (JJF) can use e.g. "perturb"
        in primal and dual.

        As far as I can see this is perfectly safe.
        */

    // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


    // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    int returnCode;
    if (!customPrimal){
        //std::cout << "IClpSimplex: continue with ClpSimplexPrimal   \n";
        returnCode = reinterpret_cast<ClpSimplexPrimal *> (this)->primal(ifValuesPass,startFinishOptions);
    }
    else {
        //std::cout << "IClpSimplex L280: casting to IClpSimplexPrimal\n";
        returnCode = reinterpret_cast<IClpSimplexPrimal *> (this)->primal(ifValuesPass,startFinishOptions);
    }
    //int lastAlgorithm=1;

    if (problemStatus_==10) {
        //lastAlgorithm=-1;
        //printf("Cleaning up with dual\n");
        int savePerturbation = perturbation_;
        perturbation_=100;
        bool denseFactorization = initialDenseFactorization();
        // It will be safe to allow dense
        setInitialDenseFactorization(true);
        // check which algorithms allowed
        int dummy;
        baseIteration_=numberIterations_;
        if ((matrix_->generalExpanded(this,4,dummy)&2)!=0&&(specialOptions_&8192)==0) {
            double saveBound = dualBound_;
            // upperOut_ has largest away from bound
            dualBound_=std::min(std::max(2.0*upperOut_,1.0e8),dualBound_);
            returnCode = reinterpret_cast<ClpSimplexDual *> (this)->dual(0,startFinishOptions);
            dualBound_=saveBound;
        } else {
            if (!customPrimal){
                std::cout << "IClpSimplex: continue with ClpSimplexPrimal   \n";
                returnCode = reinterpret_cast<ClpSimplexPrimal *> (this)->primal(0,startFinishOptions);
            }else {
                std::cout << "IClpSimplex: casting to IClpSimplexPrimal\n";
                returnCode = reinterpret_cast<IClpSimplexPrimal *> (this)->primal(0,startFinishOptions);
            }
        }

        baseIteration_=0;
        setInitialDenseFactorization(denseFactorization);
        perturbation_=savePerturbation;
        if (problemStatus_==10)
            problemStatus_=0;
    }
    //factorization_->pivotTolerance(savedPivotTolerance);
    onStopped(); // set secondary status if stopped
    //if (problemStatus_==1&&lastAlgorithm==1)
    //returnCode=10; // so will do primal after postsolve

    //delete tempRow;
    //delete tempRow_vector;
    //delete QP_BanList;


    return returnCode;
}


double cdot(CoinIndexedVector* pv1, CoinIndexedVector* pv2){
    double sum = 0;
    int	size = pv1->getNumElements();
    int* indices = pv1->getIndices();

    for (int i = 0; i < size; i++)
        sum += (*pv1)[indices[i]] * (*pv2)[indices[i]];
    return sum;

}

PyObject* IClpSimplex::filterVars(PyObject* inds){
    if (!PyArray_Check(inds)){
        PyErr_SetString(PyExc_ValueError,
                "filterVars: inds should be a numpy array.");
        return NULL;
    }

    npy_intp inds_len = PyArray_DIM(reinterpret_cast<PyArrayObject*>(inds), 0);
    if (inds_len == 0){
        npy_intp dims = 0;
        PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT, tempIntArray );
        return Arr;
    }
    if (tempArrayExists == false)
        createTempArray();

    int ind_count = 0;

    PyObject* inds_it= PyArray_IterNew(inds);
    int i;
    double bestRc = 0;
    double* rc = djRegion();
    while (PyArray_ITER_NOTDONE(inds_it)){
        i = *(int*)PyArray_ITER_DATA(inds_it);
        if (fabs(rc[i]) < bestRc){
            PyArray_ITER_NEXT(inds_it);
            continue;
        }
        if (checkVar(i)){
            tempIntArray[ind_count++] = i;
            bestRc = fabs(rc[i]);
        }
        PyArray_ITER_NEXT(inds_it);
    }

    npy_intp dims = ind_count;
    PyObject *Arr = PyArray_SimpleNewFromData( 1, &dims, NPY_INT, tempIntArray );
    return Arr;

}



================================================
FILE: cylp/cpp/IClpSimplex.hpp
================================================
#ifndef IClpSimplex_H
#define IClpSimplex_H

//#define NPY_NO_DEPRECATED_API
//#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION

//#include "ClpModel.hpp"
#include "ClpSimplex.hpp"
#include "ClpPresolve.hpp"
#include "ClpLinearObjective.hpp"
#include "CoinIndexedVector.hpp"
#include "ClpFactorization.hpp"
#include "Python.h"
#include <numpy/arrayobject.h>
#include "ICbcModel.hpp"
#include "ClpParameters.hpp"

#include "ICoinPackedMatrix.hpp"


//#include "ClpSimplexPrimal.hpp"

typedef int (*runIsPivotAcceptable_t)(void *instance);
typedef int (*varSelCriteria_t)(void *instance, int varInd);


class IClpSimplex : public ClpSimplex{
public:
    ClpPresolve pinfo;
    IClpSimplex(const ClpSimplex &rhs,PyObject *obj,
                            runIsPivotAcceptable_t runPivotRow,
                            varSelCriteria_t RunVarSelCriteria,
                            int useCustomPrimal, int scalingMode=-1 );
	IClpSimplex(PyObject *obj, runIsPivotAcceptable_t runPivotRow,
                varSelCriteria_t RunVarSelCriteria );
    int initialSolve(int preSolveType=ClpSolve::presolveOn);
	// For initializing instances that are build using ClpSimplex consructor (NOT IClpSimplex)
    void setCriteria(varSelCriteria_t vsc);

    int argWeightedMax(PyObject* arr, PyObject* whr, double weight);
    int argWeightedMax(PyObject* arr, PyObject* arr_ind, PyObject* w, PyObject* w_ind);

    PyObject *obj;
  	runIsPivotAcceptable_t runIsPivotAcceptable;
	int isPivotAcceptable();

    varSelCriteria_t varSelCriteria;
    int checkVar(int varInd);
    PyObject* filterVars(PyObject* inds);
    int* tempIntArray;
    bool tempArrayExists;
    void createTempArray(void);

    int* QP_ComplementarityList;
	int* QP_BanList;
	int QP_ExistsBannedVariable;

	void setComplementarityList(int *);
	int* ComplementarityList();

    bool varIsFree(int ind);
    bool varBasic(int ind);
    bool varAtUpperBound(int ind);
    bool varAtLowerBound(int ind);
    bool varSuperBasic(int ind);
    bool varIsFixed(int ind);
	PyObject * getReducedCosts();
	void setReducedCosts(double*);
    PyObject * getStatusArray();
	PyObject * getComplementarityList();
	PyObject * getPivotVariable();
	PyObject * getPrimalRowSolution();
	PyObject * getPrimalColumnSolution();
    PyObject * getPrimalColumnSolutionAll();
    PyObject * getSolutionRegion();
    PyObject * getCostRegion();
	PyObject * getDualRowSolution();
	PyObject * getDualColumnSolution();
	PyObject * getObjective();
	PyObject * getRowLower();
	PyObject * getRowUpper();
	PyObject * getColLower();
    PyObject * getColUpper();
    PyObject * getColumnScale();
    PyObject * getRowScale();


    PyObject* getLower();
    PyObject* getUpper();

    PyObject* getIntegerInformation();




	void getBInvACol(int col, double* vec);
	void getACol(int ncol, CoinIndexedVector * colArray);
  int updateColumnFT(CoinIndexedVector * spare,
                          CoinIndexedVector * updatedColumn)
      {
      return this->factorization()->updateColumnFT(spare, updatedColumn);
      }

  int updateColumnTranspose (CoinIndexedVector * regionSparse,
                                 CoinIndexedVector * regionSparse2){
      return this->factorization()->updateColumnTranspose(regionSparse, regionSparse2);
      }

	int customPrimal;
	void useCustomPrimal(int);
	int getUseCustomPrimal();


	void setPrimalColumnPivotAlgorithm(ClpPrimalColumnPivot *choice){ClpSimplex::setPrimalColumnPivotAlgorithm(*choice);}
  void setDualRowPivotAlgorithm(ClpDualRowPivot *choice){ClpSimplex::setDualRowPivotAlgorithm(*choice);}

    void loadQuadraticObjective(const CoinPackedMatrix* matrix){ClpModel::loadQuadraticObjective(*matrix);}
    ICoinPackedMatrix* getMatrix(){return static_cast<ICoinPackedMatrix*>(ClpModel::matrix());}

	int loadProblem (CoinModel * modelObject,bool tryPlusMinusOne=false){return ClpSimplex::loadProblem(*modelObject, tryPlusMinusOne);}
	//double* infeasibilityRay();
    void loadProblem (const CoinPackedMatrix* matrix,
		     const double* collb, const double* colub,
		     const double* obj,
		     const double* rowlb, const double* rowub,
		     const double * rowObjective=NULL){
                   ClpSimplex::loadProblem(*matrix, collb, colub, obj, rowlb, rowub, rowObjective);}

	int primal(int ifValuesPass=0, int startFinishOptions=0);

	IClpSimplex (ClpSimplex * wholeModel,
	      int numberColumns, const int * whichColumns);

	~IClpSimplex();

	void dualExpanded(ClpSimplex * model,CoinIndexedVector * array, double * other,int mode);


	void convertBoundToSense(const double lower, const double upper,
						 double& right);
	void extractSenseRhsRange(double* rhs_);
	void getRightHandSide(double* righthandside);


	double* tempRow;
	CoinIndexedVector* tempRow_vector;

	void vectorTimesB_1(CoinIndexedVector*);
    void transposeTimesSubsetAll(int number, long long int* which, double* pi, double* y);
    void transposeTimesSubset(int number, int* which, double* pi, double* y);
    void transposeTimes(const ClpSimplex * model, double scalar,
                                 const CoinIndexedVector * x,
                                 CoinIndexedVector * y,
                                 CoinIndexedVector * z);

    IClpSimplex*	preSolve(IClpSimplex* si,
                              double feasibilityTolerance=0.0,
                              bool keepIntegers=true,
                              int numberPasses=5,
                              bool dropNames=false,
                              bool doRowObjective=false);
    void postSolve(bool updateStatus=true);

    int dualWithPresolve(IClpSimplex* si,
                              double feasibilityTolerance=0.0,
                              bool keepIntegers=true,
                              int numberPasses=5,
                              bool dropNames=false,
                              bool doRowObjective=false);

    int primalWithPresolve(IClpSimplex* si,
                              double feasibilityTolerance=0.0,
                              bool keepIntegers=true,
                              int numberPasses=5,
                              bool dropNames=false,
                              bool doRowObjective=false);

    void setComplement(int var1, int var2){QP_ComplementarityList[var1] = var2; QP_ComplementarityList[var2] = var1;}


    inline double getCoinInfinity(){return COIN_DBL_MAX;}

    inline void setColumnUpperArray(double *cu){columnUpper_ = cu;}
    inline void setColumnLowerArray(double *cl){columnLower_ = cl;}
    inline void setRowUpperArray(double *ru){rowUpper_ = ru;}
    inline void setRowLowerArray(double *rl){rowLower_ = rl;}

    inline void setColumnUpperSubset(int n, int *indicesOfIndices, int *indices, double* values){
        for (int i = 0 ; i < n ; i++)
            setColumnUpper(indices[indicesOfIndices[i]], values[indicesOfIndices[i]]);
    }
    inline void setColumnLowerSubset(int n, int *indicesOfIndices, int *indices, double* values){
        for (int i = 0 ; i < n ; i++)
            setColumnLower(indices[indicesOfIndices[i]], values[indicesOfIndices[i]]);
    }

    inline void setColumnUpperFirstElements(int n, double* values){
        for (int i = 0 ; i < n ; i++)
            setColumnUpper(i, values[i]);
    }
    inline void setColumnLowerFirstElements(int n, double* values){
        for (int i = 0 ; i < n ; i++)
            setColumnLower(i, values[i]);
    }

    inline void setObjectiveArray(double *o, int numberColumns)
    {
    if (objective_)
    	delete objective_;
    objective_ = new ClpLinearObjective(o, numberColumns);
    }

	void setVariableName(int varInd,  char* name);
    void setConstraintName(int constInd,  char* name);
    std::vector<std::string> getVariableNames();

    /// Partial pricing
    int partialPrice(int start, int end, int* numberWanted)
      {
       int bestVarInd;
       this->clpMatrix()->partialPricing(this,
                                          static_cast<double>(start),
                                          static_cast<double>(end),
                                          bestVarInd,
                                          *numberWanted);
        return bestVarInd;
        }

    ICbcModel* getICbcModel();
    void writeLp(const char *filename,
                       const char *extension = "lp",
                       double epsilon = 1e-5,
                       int numberAcross = 10,
                       int decimals = 5,
                       double objSense = 0.0,
                       bool useRowNames = true);

    void setBasisStatus(const int* cstat, const int* rstat);
    void getBasisStatus(int* cstat, int* rstat);

    void setMaxNumIteration(int m);

};

double cdot(CoinIndexedVector* v1, CoinIndexedVector* v2);


#endif


================================================
FILE: cylp/cpp/IClpSimplexPrimal.cpp
================================================
// Copyright (C) 2002, International Business Machines
// Corporation and others.  All Rights Reserved.

/* Notes on implementation of primal simplex algorithm.

 When primal feasible(A):

 If dual feasible, we are optimal.  Otherwise choose an infeasible
 basic variable to enter basis from a bound (B).  We now need to find an
 outgoing variable which will leave problem primal feasible so we get
 the column of the tableau corresponding to the incoming variable
 (with the correct sign depending if variable will go up or down).

 We now perform a ratio test to determine which outgoing variable will
 preserve primal feasibility (C).  If no variable found then problem
 is unbounded (in primal sense).  If there is a variable, we then
 perform pivot and repeat.  Trivial?

 -------------------------------------------

 A) How do we get primal feasible?  All variables have fake costs
 outside their feasible region so it is trivial to declare problem
 feasible.  OSL did not have a phase 1/phase 2 approach but
 instead effectively put an extra cost on infeasible basic variables
 I am taking the same approach here, although it is generalized
 to allow for non-linear costs and dual information.

 In OSL, this weight was changed heuristically, here at present
 it is only increased if problem looks finished.  If problem is
 feasible I check for unboundedness.  If not unbounded we
 could play with going into dual.  As long as weights increase
 any algorithm would be finite.

 B) Which incoming variable to choose is a virtual base class.
 For difficult problems steepest edge is preferred while for
 very easy (large) problems we will need partial scan.

 C) Sounds easy, but this is hardest part of algorithm.
 1) Instead of stopping at first choice, we may be able
 to allow that variable to go through bound and if objective
 still improving choose again.  These mini iterations can
 increase speed by orders of magnitude but we may need to
 go to more of a bucket choice of variable rather than looking
 at them one by one (for speed).
 2) Accuracy.  Basic infeasibilities may be less than
 tolerance.  Pivoting on these makes objective go backwards.
 OSL modified cost so a zero move was made, Gill et al
 modified so a strictly positive move was made.
 The two problems are that re-factorizations can
 change rinfeasibilities above and below tolerances and that when
 finished we need to reset costs and try again.
 3) Degeneracy.  Gill et al helps but may not be enough.  We
 may need more.  Also it can improve speed a lot if we perturb
 the rhs and bounds significantly.

 References:
 Forrest and Goldfarb, Steepest-edge simplex algorithms for
 linear programming - Mathematical Programming 1992
 Forrest and Tomlin, Implementing the simplex method for
 the Optimization Subroutine Library - IBM Systems Journal 1992
 Gill, Murray, Saunders, Wright A Practical Anti-Cycling
 Procedure for Linear and Nonlinear Programming SOL report 1988


 TODO:

 a) Better recovery procedures.  At present I never check on forward
 progress.  There is checkpoint/restart with reducing
 re-factorization frequency, but this is only on singular
 factorizations.
 b) Fast methods for large easy problems (and also the option for
 the code to automatically choose which method).
 c) We need to be able to stop in various ways for OSI - this
 is fairly easy.

 */

#include "CoinPragma.hpp"

#include <math.h>

#include "CoinHelperFunctions.hpp"
#include "IClpSimplexPrimal.hpp"
#include "ClpFactorization.hpp"
#include "ClpNonLinearCost.hpp"
#include "CoinPackedMatrix.hpp"
#include "CoinIndexedVector.hpp"
#include "ClpPrimalColumnPivot.hpp"
#include "ClpMessage.hpp"
#include "ClpEventHandler.hpp"
#include <cfloat>
#include <cassert>
#include <string>
#include <stdio.h>
#include <iostream>


#include "CyClpSimplex_api.h"

// primal
int IClpSimplexPrimal::primal (int ifValuesPass , int startFinishOptions)
{

	/*
	 Method

     It tries to be a single phase approach with a weight of 1.0 being
     given to getting optimal and a weight of infeasibilityCost_ being
     given to getting primal feasible.  In this version I have tried to
     be clever in a stupid way.  The idea of fake bounds in dual
     seems to work so the primal analogue would be that of getting
     bounds on reduced costs (by a presolve approach) and using
     these for being above or below feasible region.  I decided to waste
     memory and keep these explicitly.  This allows for non-linear
     costs!

     The code is designed to take advantage of sparsity so arrays are
     seldom zeroed out from scratch or gone over in their entirety.
     The only exception is a full scan to find incoming variable for
     Dantzig row choice.  For steepest edge we keep an updated list
     of dual infeasibilities (actually squares).
     On easy problems we don't need full scan - just
     pick first reasonable.

     One problem is how to tackle degeneracy and accuracy.  At present
     I am using the modification of costs which I put in OSL and which was
     extended by Gill et al.  I am still not sure of the exact details.

     The flow of primal is three while loops as follows:

     while (not finished) {

	 while (not clean solution) {

	 Factorize and/or clean up solution by changing bounds so
	 primal feasible.  If looks finished check fake primal bounds.
	 Repeat until status is iterating (-1) or finished (0,1,2)

	 }

	 while (status==-1) {

	 Iterate until no pivot in or out or time to re-factorize.

	 Flow is:

	 choose pivot column (incoming variable).  if none then
	 we are primal feasible so looks as if done but we need to
	 break and check bounds etc.

	 Get pivot column in tableau

	 Choose outgoing row.  If we don't find one then we look
	 primal unbounded so break and check bounds etc.  (Also the
	 pivot tolerance is larger after any iterations so that may be
	 reason)

	 If we do find outgoing row, we may have to adjust costs to
	 keep going forwards (anti-degeneracy).  Check pivot will be stable
	 and if unstable throw away iteration and break to re-factorize.
	 If minor error re-factorize after iteration.

	 Update everything (this may involve changing bounds on
	 variables to stay primal feasible.

	 }

     }

     At present we never check we are going forwards.  I overdid that in
     OSL so will try and make a last resort.

     Needs partial scan pivot in option.

     May need other anti-degeneracy measures, especially if we try and use
     loose tolerances as a way to solve in fewer iterations.

     I like idea of dynamic scaling.  This gives opportunity to decouple
     different implications of scaling for accuracy, iteration count and
     feasibility tolerance.

	 */

	 // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	 //int listSize = numberRows() + numberColumns();

	 //QP_ComplementarityList = new int[listSize];

	//for (int i = 0 ; i < listSize ; i++)
	//	QP_ComplementarityList[i] = i;

	//QP_ComplementarityList[0] = 2;
	//QP_ComplementarityList[2] = 0;


	//QP_BanList = new int[listSize];
	//for (int i = 0; i < listSize ; i++)
	//	QP_BanList[i] = 0;

	//QP_ExistsBannedVariable = 0;
	// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


	algorithm_ = +1;
	moreSpecialOptions_ &= ~16; // clear check replaceColumn accuracy

	// save data
	ClpDataSave data = saveData();
	matrix_->refresh(this); // make sure matrix okay


	// Save so can see if doing after dual
	int initialStatus=problemStatus_;
	int initialIterations = numberIterations_;
	int initialNegDjs=-1;
	// initialize - maybe values pass and algorithm_ is +1
#if 0
	// if so - put in any superbasic costed slacks
	if (ifValuesPass&&specialOptions_<0x01000000) {
		// Get column copy
		const CoinPackedMatrix * columnCopy = matrix();
		const int * row = columnCopy->getIndices();
		const CoinBigIndex * columnStart = columnCopy->getVectorStarts();
		const int * columnLength = columnCopy->getVectorLengths();
		//const double * element = columnCopy->getElements();
		int n=0;
		for (int iColumn = 0;iColumn<numberColumns_;iColumn++) {
			if (columnLength[iColumn]==1) {
				Status status = getColumnStatus(iColumn);
				if (status!=basic&&status!=isFree) {
					double value = columnActivity_[iColumn];
					if (fabs(value-columnLower_[iColumn])>primalTolerance_&&
						fabs(value-columnUpper_[iColumn])>primalTolerance_) {
						int iRow = row[columnStart[iColumn]];
						if (getRowStatus(iRow)==basic) {
							setRowStatus(iRow,superBasic);
							setColumnStatus(iColumn,basic);
							n++;
						}
					}
				}
			}
		}
		printf("%d costed slacks put in basis\n",n);
	}
#endif



	if (!startup(ifValuesPass,startFinishOptions)) {

		// Set average theta
		nonLinearCost_->setAverageTheta(1.0e3);
		int lastCleaned=0; // last time objective or bounds cleaned up

		// Say no pivot has occurred (for steepest edge and updates)
		pivotRow_=-2;

		// This says whether to restore things etc
		int factorType=0;
		if (problemStatus_<0&&perturbation_<100&&!ifValuesPass) {
			perturb(0);
			// Can't get here if values pass
			assert (!ifValuesPass);
			gutsOfSolution(NULL,NULL);
			if (handler_->logLevel()>2) {
				handler_->message(CLP_SIMPLEX_STATUS,messages_)
				<<numberIterations_<<objectiveValue();
				handler_->printing(sumPrimalInfeasibilities_>0.0)
				<<sumPrimalInfeasibilities_<<numberPrimalInfeasibilities_;
				handler_->printing(sumDualInfeasibilities_>0.0)
				<<sumDualInfeasibilities_<<numberDualInfeasibilities_;
				handler_->printing(numberDualInfeasibilitiesWithoutFree_
								   <numberDualInfeasibilities_)
				<<numberDualInfeasibilitiesWithoutFree_;
				handler_->message()<<CoinMessageEol;
			}
		}
		IClpSimplex * saveModel=NULL;
		int stopSprint=-1;
		int sprintPass=0;
		int reasonableSprintIteration=0;
		int lastSprintIteration=0;
		double lastObjectiveValue=COIN_DBL_MAX;
		// Start check for cycles
		progress_.fillFromModel(this);
		progress_.startCheck();




		/*
		 Status of problem:
		 0 - optimal
		 1 - infeasible
		 2 - unbounded
		 -1 - iterating
		 -2 - factorization wanted
		 -3 - redo checking without factorization
		 -4 - looks infeasible
		 -5 - looks unbounded
		 */
		while (problemStatus_<0) {

			int iRow,iColumn;
			// clear
			for (iRow=0;iRow<4;iRow++) {
				rowArray_[iRow]->clear();
			}

			for (iColumn=0;iColumn<2;iColumn++) {
				columnArray_[iColumn]->clear();
			}


			// give matrix (and model costs and bounds a chance to be
			// refreshed (normally null)
			matrix_->refresh(this);
			// If getting nowhere - why not give it a kick
#if 1
			if (perturbation_<101&&numberIterations_>2*(numberRows_+numberColumns_)&&(specialOptions_&4)==0
				&&initialStatus!=10) {
				perturb(1);
				matrix_->rhsOffset(this,true,false);
			}
#endif


			// If we have done no iterations - special
			if (lastGoodIteration_==numberIterations_&&factorType)
				factorType=3;
			if (saveModel) {
				// Doing sprint
				if (sequenceIn_<0||numberIterations_>=stopSprint) {
					problemStatus_=-1;
					originalModel(saveModel);
					saveModel=NULL;
					if (sequenceIn_<0&&numberIterations_<reasonableSprintIteration&&
						sprintPass>100)
						primalColumnPivot_->switchOffSprint();
					//lastSprintIteration=numberIterations_;
					printf("End small model\n");
				}
			}




			// may factorize, checks if problem finished
			statusOfProblemInPrimal(lastCleaned,factorType,&progress_,true,ifValuesPass,saveModel);


			if (initialStatus==10) {


				// cleanup phase
				if(initialIterations != numberIterations_) {
					if (numberDualInfeasibilities_>10000&&numberDualInfeasibilities_>10*initialNegDjs) {
						// getting worse - try perturbing
						if (perturbation_<101&&(specialOptions_&4)==0) {

							perturb(1);
							matrix_->rhsOffset(this,true,false);
							statusOfProblemInPrimal(lastCleaned,factorType,&progress_,true,ifValuesPass,saveModel);
						}
					}
				} else {

					// save number of negative djs
					if (!numberPrimalInfeasibilities_)
						initialNegDjs=numberDualInfeasibilities_;
					// make sure weight won't be changed
					if (infeasibilityCost_==1.0e10)
						infeasibilityCost_=1.000001e10;
				}
			}



			// See if sprint says redo because of problems
			if (numberDualInfeasibilities_==-776) {
				// Need new set of variables
				problemStatus_=-1;

				originalModel(saveModel);

				saveModel=NULL;
				//lastSprintIteration=numberIterations_;
				printf("End small model after\n");
				statusOfProblemInPrimal(lastCleaned,factorType,&progress_,true,ifValuesPass,saveModel);
			}



			int numberSprintIterations=0;
			int numberSprintColumns = primalColumnPivot_->numberSprintColumns(numberSprintIterations);

			if (problemStatus_==777) {
				// problems so do one pass with normal
				problemStatus_=-1;
				originalModel(saveModel);
				saveModel=NULL;
				// Skip factorization
				//statusOfProblemInPrimal(lastCleaned,factorType,&progress_,false,saveModel);
				statusOfProblemInPrimal(lastCleaned,factorType,&progress_,true,ifValuesPass,saveModel);
			} else if (problemStatus_<0&&!saveModel&&numberSprintColumns&&firstFree_<0) {
				int numberSort=0;
				int numberFixed=0;
				int numberBasic=0;
				reasonableSprintIteration = numberIterations_ + 100;
				int * whichColumns = new int[numberColumns_];
				double * weight = new double[numberColumns_];
				int numberNegative=0;
				double sumNegative = 0.0;

				// now massage weight so all basic in plus good djs
				for (iColumn=0;iColumn<numberColumns_;iColumn++) {
					double dj = dj_[iColumn];
					switch(getColumnStatus(iColumn)) {

						case basic:
							dj = -1.0e50;
							numberBasic++;
							break;
						case atUpperBound:
							dj = -dj;
							break;
						case isFixed:
							dj=1.0e50;
							numberFixed++;
							break;
						case atLowerBound:
							dj = dj;
							break;
						case isFree:
							dj = -100.0*fabs(dj);
							break;
						case superBasic:
							dj = -100.0*fabs(dj);
							break;
					}
					if (dj<-dualTolerance_&&dj>-1.0e50) {
						numberNegative++;
						sumNegative -= dj;
					}
					weight[iColumn]=dj;
					whichColumns[iColumn] = iColumn;
				}
				handler_->message(CLP_SPRINT,messages_)
				<<sprintPass<<numberIterations_-lastSprintIteration<<objectiveValue()<<sumNegative
				<<numberNegative
				<<CoinMessageEol;
				sprintPass++;
				lastSprintIteration=numberIterations_;


				if (objectiveValue()*optimizationDirection_>lastObjectiveValue-1.0e-7&&sprintPass>5) {
					// switch off

					printf("Switching off sprint\n");
					primalColumnPivot_->switchOffSprint();
				} else {
					lastObjectiveValue = objectiveValue()*optimizationDirection_;
					// sort
					CoinSort_2(weight,weight+numberColumns_,whichColumns);
					numberSort = std::min(numberColumns_-numberFixed,numberBasic+numberSprintColumns);
					// Sort to make consistent ?
					std::sort(whichColumns,whichColumns+numberSort);
					// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
					// FIXME: uncomment
                    saveModel = new IClpSimplex(this,numberSort,whichColumns);
					// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

					delete [] whichColumns;
					delete [] weight;
					// Skip factorization
					//statusOfProblemInPrimal(lastCleaned,factorType,&progress_,false,saveModel);
					//statusOfProblemInPrimal(lastCleaned,factorType,&progress_,true,saveModel);
					stopSprint = numberIterations_+numberSprintIterations;
					printf("Sprint with %d columns for %d iterations\n",
						   numberSprintColumns,numberSprintIterations);
				}


			}



			// Say good factorization
			factorType=1;

			// Say no pivot has occurred (for steepest edge and updates)
			pivotRow_=-2;

			// exit if victory declared
			if (problemStatus_>=0)
				break;

			// test for maximum iterations
			if (hitMaximumIterations()||(ifValuesPass==2&&firstFree_<0)) {
				problemStatus_=3;
				break;
			}

			if (firstFree_<0) {
				if (ifValuesPass) {
					// end of values pass
					ifValuesPass=0;
					int status = eventHandler_->event(ClpEventHandler::endOfValuesPass);
					if (status>=0) {
						problemStatus_=5;
						secondaryStatus_=ClpEventHandler::endOfValuesPass;
						break;
					}
					//#define FEB_TRY
#ifdef FEB_TRY
					if (perturbation_<100)
						perturb(0);
#endif
				}
			}
			// Check event
			{
				int status = eventHandler_->event(ClpEventHandler::endOfFactorization);
				if (status>=0) {
					problemStatus_=5;
					secondaryStatus_=ClpEventHandler::endOfFactorization;
					break;
				}
			}
			// Iterate
			whileIterating(ifValuesPass ? 1 : 0);
		}
	}
	// if infeasible get real values
	//printf("XXXXY final cost %g\n",infeasibilityCost_);
	progress_.initialWeight_=0.0;
	if (problemStatus_==1&&secondaryStatus_!=6) {
		infeasibilityCost_=0.0;
		createRim(1+4);
		delete nonLinearCost_;
		nonLinearCost_ = new ClpNonLinearCost(this);
		nonLinearCost_->checkInfeasibilities(0.0);
		sumPrimalInfeasibilities_=nonLinearCost_->sumInfeasibilities();
		numberPrimalInfeasibilities_= nonLinearCost_->numberInfeasibilities();
		// and get good feasible duals
		computeDuals(NULL);
	}
	// clean up
	unflag();
	finish(startFinishOptions);
	restoreData(data);
	return problemStatus_;
}
/*
 Reasons to come out:
 -1 iterations etc
 -2 inaccuracy
 -3 slight inaccuracy (and done iterations)
 -4 end of values pass and done iterations
 +0 looks optimal (might be infeasible - but we will investigate)
 +2 looks unbounded
 +3 max iterations
 */
int
IClpSimplexPrimal::whileIterating(int valuesOption)
{
	// Say if values pass
	int ifValuesPass=(firstFree_>=0) ? 1 : 0;
	int returnCode=-1;
	int superBasicType=1;
	if (valuesOption>1)
		superBasicType=3;
	// status stays at -1 while iterating, >=0 finished, -2 to invert
	// status -3 to go to top without an invert
	while (problemStatus_==-1) {
		//#define CLP_DEBUG 1
#ifdef CLP_DEBUG
		{
			int i;
			// not [1] as has information
			for (i=0;i<4;i++) {
				if (i!=1)
					rowArray_[i]->checkClear();
			}
			for (i=0;i<2;i++) {
				columnArray_[i]->checkClear();
			}
		}
#endif
#if 0
		{
			int iPivot;
			double * array = rowArray_[3]->denseVector();
			int * index = rowArray_[3]->getIndices();
			int i;
			for (iPivot=0;iPivot<numberRows_;iPivot++) {
				int iSequence = pivotVariable_[iPivot];
				unpackPacked(rowArray_[3],iSequence);
				factorization_->updateColumn(rowArray_[2],rowArray_[3]);
				int number = rowArray_[3]->getNumElements();
				for (i=0;i<number;i++) {
					int iRow = index[i];
					if (iRow==iPivot)
						assert (fabs(array[i]-1.0)<1.0e-4);
					else
						assert (fabs(array[i])<1.0e-4);
				}
				rowArray_[3]->clear();
			}
		}
#endif
#if 0
		nonLinearCost_->checkInfeasibilities(primalTolerance_);
		printf("suminf %g number %d\n",nonLinearCost_->sumInfeasibilities(),
			   nonLinearCost_->numberInfeasibilities());
#endif
#if CLP_DEBUG>2
		// very expensive
		if (numberIterations_>0&&numberIterations_<100&&!ifValuesPass) {
			handler_->setLogLevel(63);
			double saveValue = objectiveValue_;
			double * saveRow1 = new double[numberRows_];
			double * saveRow2 = new double[numberRows_];
			CoinMemcpyN(rowReducedCost_,numberRows_,saveRow1);
			CoinMemcpyN(rowActivityWork_,numberRows_,saveRow2);
			double * saveColumn1 = new double[numberColumns_];
			double * saveColumn2 = new double[numberColumns_];
			CoinMemcpyN(reducedCostWork_,numberColumns_,saveColumn1);
			CoinMemcpyN(columnActivityWork_,numberColumns_,saveColumn2);
			gutsOfSolution(NULL,NULL,false);
			printf("xxx %d old obj %g, recomputed %g, sum primal inf %g\n",
				   numberIterations_,
				   saveValue,objectiveValue_,sumPrimalInfeasibilities_);
			CoinMemcpyN(saveRow1,numberRows_,rowReducedCost_);
			CoinMemcpyN(saveRow2,numberRows_,rowActivityWork_);
			CoinMemcpyN(saveColumn1,numberColumns_,reducedCostWork_);
			CoinMemcpyN(saveColumn2,numberColumns_,columnActivityWork_);
			delete [] saveRow1;
			delete [] saveRow2;
			delete [] saveColumn1;
			delete [] saveColumn2;
			objectiveValue_=saveValue;
		}
#endif
		if (!ifValuesPass) {
			// choose column to come in
			// can use pivotRow_ to update weights
			// pass in list of cost changes so can do row updates (rowArray_[1])
			// NOTE rowArray_[0] is used by computeDuals which is a
			// slow way of getting duals but might be used
			primalColumn(rowArray_[1],rowArray_[2],rowArray_[3],
						 columnArray_[0],columnArray_[1]);
		} else {
			// in values pass
			int sequenceIn=nextSuperBasic(superBasicType,columnArray_[0]);
			if (valuesOption>1)
				superBasicType=2;
			if (sequenceIn<0) {
				// end of values pass - initialize weights etc
				handler_->message(CLP_END_VALUES_PASS,messages_)
				<<numberIterations_;
				primalColumnPivot_->saveWeights(this,5);
				problemStatus_=-2; // factorize now
				pivotRow_=-1; // say no weights update
				returnCode=-4;
				// Clean up
				int i;
				for (i=0;i<numberRows_+numberColumns_;i++) {
					if (getColumnStatus(i)==atLowerBound||getColumnStatus(i)==isFixed)
						solution_[i]=lower_[i];
					else if (getColumnStatus(i)==atUpperBound)
						solution_[i]=upper_[i];
				}
				break;
			} else {
				// normal
				sequenceIn_ = sequenceIn;
				valueIn_=solution_[sequenceIn_];
				lowerIn_=lower_[sequenceIn_];
				upperIn_=upper_[sequenceIn_];
				dualIn_=dj_[sequenceIn_];
			}
		}
		pivotRow_=-1;
		sequenceOut_=-1;
		rowArray_[1]->clear();
		if (sequenceIn_>=0) {
			// we found a pivot column
			assert (!flagged(sequenceIn_));
#ifdef CLP_DEBUG
			if ((handler_->logLevel()&32)) {
				char x = isColumn(sequenceIn_) ? 'C' :'R';
				std::cout<<"pivot column "<<
				x<<sequenceWithin(sequenceIn_)<<std::endl;
			}
#endif
#ifdef CLP_DEBUG
			{
				int checkSequence=-2077;
				if (checkSequence>=0&&checkSequence<numberRows_+numberColumns_&&!ifValuesPass) {
					rowArray_[2]->checkClear();
					rowArray_[3]->checkClear();
					double * array = rowArray_[3]->denseVector();
					int * index = rowArray_[3]->getIndices();
					unpackPacked(rowArray_[3],checkSequence);
					factorization_->updateColumnForDebug(rowArray_[2],rowArray_[3]);
					int number = rowArray_[3]->getNumElements();
					double dualIn = cost_[checkSequence];
					int i;
					for (i=0;i<number;i++) {
						int iRow = index[i];
						int iPivot = pivotVariable_[iRow];
						double alpha = array[i];
						dualIn -= alpha*cost_[iPivot];
					}
					printf("old dj for %d was %g, recomputed %g\n",checkSequence,
						   dj_[checkSequence],dualIn);
					rowArray_[3]->clear();
					if (numberIterations_>2000)
						exit(1);
				}
			}
#endif
			// do second half of iteration
			returnCode = pivotResult(ifValuesPass);
			if (returnCode<-1&&returnCode>-5) {
				problemStatus_=-2; //
			} else if (returnCode==-5) {
				if ((moreSpecialOptions_&16)==0&&factorization_->pivots()) {
					moreSpecialOptions_ |= 16;
					problemStatus_=-2;
				}
				// otherwise something flagged - continue;
			} else if (returnCode==2) {
				problemStatus_=-5; // looks unbounded
			} else if (returnCode==4) {
				problemStatus_=-2; // looks unbounded but has iterated
			} else if (returnCode!=-1) {
				assert(returnCode==3);
				if (problemStatus_!=5)
					problemStatus_=3;
			}
		} else {
			// no pivot column
#ifdef CLP_DEBUG
			if (handler_->logLevel()&32)
				printf("** no column pivot\n");
#endif
			if (nonLinearCost_->numberInfeasibilities())
				problemStatus_=-4; // might be infeasible
			// Force to re-factorize early next time
			int numberPivots = factorization_->pivots();
			forceFactorization_=std::min(forceFactorization_,(numberPivots+1)>>1);
			returnCode=0;
			break;
		}
	}
	if (valuesOption>1)
		columnArray_[0]->setNumElements(0);
	return returnCode;
}
/* Checks if finished.  Updates status */
void
IClpSimplexPrimal::statusOfProblemInPrimal(int & lastCleaned,int type,
												 ClpSimplexProgress * progress,
												 bool doFactorization,
												 int ifValuesPass,
												 IClpSimplex * originalModel)
{
	int dummy; // for use in generalExpanded
	int saveFirstFree=firstFree_;
	// number of pivots done
	int numberPivots = factorization_->pivots();
	if (type==2) {
		// trouble - restore solution
		CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
		CoinMemcpyN(savedSolution_+numberColumns_ ,
					numberRows_,rowActivityWork_);
		CoinMemcpyN(savedSolution_ ,
					numberColumns_,columnActivityWork_);
		// restore extra stuff
		matrix_->generalExpanded(this,6,dummy);
		forceFactorization_=1; // a bit drastic but ..
		pivotRow_=-1; // say no weights update
		changeMade_++; // say change made
	}

	int saveThreshold = factorization_->sparseThreshold();
	int tentativeStatus = problemStatus_;
	int numberThrownOut=1; // to loop round on bad factorization in values pass
	double lastSumInfeasibility=COIN_DBL_MAX;
	if (numberIterations_)
		lastSumInfeasibility=nonLinearCost_->sumInfeasibilities();
	int nPass=0;
	while (numberThrownOut) {

		int nSlackBasic=0;
		if (nPass) {
			for (int i=0;i<numberRows_;i++) {
				if (getRowStatus(i)==basic)
					nSlackBasic++;
			}
		}

		nPass++;
		if (problemStatus_>-3||problemStatus_==-4) {
			// factorize
			// later on we will need to recover from singularities
			// also we could skip if first time
			// do weights
			// This may save pivotRow_ for use
			if (doFactorization)
				primalColumnPivot_->saveWeights(this,1);

			if ((type&&doFactorization)||nSlackBasic==numberRows_) {
				// is factorization okay?
				int factorStatus = internalFactorize(1);

				if (factorStatus) {
					if (solveType_==2+8) {
						// say odd
						problemStatus_=5;
						return;
					}
					if (type!=1||largestPrimalError_>1.0e3
						||largestDualError_>1.0e3) {
						// switch off dense
						int saveDense = factorization_->denseThreshold();

						factorization_->setDenseThreshold(0);
						// Go to safe
						factorization_->pivotTolerance(0.99);
						// make sure will do safe factorization
						pivotVariable_[0]=-1;
						internalFactorize(2);
						factorization_->setDenseThreshold(saveDense);
						// restore extra stuff
						matrix_->generalExpanded(this,6,dummy);
					} else {
						// no - restore previous basis
						// Keep any flagged variables

						int i;
						for (i=0;i<numberRows_+numberColumns_;i++) {
							if (flagged(i))
								saveStatus_[i] |= 64; //say flagged
						}
						CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
						if (numberPivots<=1) {
							// throw out something
							if (sequenceIn_>=0&&getStatus(sequenceIn_)!=basic) {
								setFlagged(sequenceIn_);
							} else if (sequenceOut_>=0&&getStatus(sequenceOut_)!=basic) {
								setFlagged(sequenceOut_);
							}

							double newTolerance = std::max(0.5 + 0.499*randomNumberGenerator_.randomDouble(),factorization_->pivotTolerance());
							factorization_->pivotTolerance(newTolerance);
						} else {
							// Go to safe
							factorization_->pivotTolerance(0.99);
						}

						CoinMemcpyN(savedSolution_+numberColumns_ ,
									numberRows_,rowActivityWork_);
						CoinMemcpyN(savedSolution_ ,
									numberColumns_,columnActivityWork_);
						// restore extra stuff
						matrix_->generalExpanded(this,6,dummy);
						matrix_->generalExpanded(this,5,dummy);

						forceFactorization_=1; // a bit drastic but ..
						type = 2;
						if (internalFactorize(2)!=0) {
							largestPrimalError_=1.0e4; // force other type
						}
					}
					changeMade_++; // say change made
				}
			}
			if (problemStatus_!=-4)
				problemStatus_=-3;
		}

		// at this stage status is -3 or -5 if looks unbounded
		// get primal and dual solutions
		// put back original costs and then check
		// createRim(4); // costs do not change
		// May need to do more if column generation
		dummy=4;
		matrix_->generalExpanded(this,9,dummy);
		numberThrownOut=gutsOfSolution(NULL,NULL,(firstFree_>=0));
		double sumInfeasibility =  nonLinearCost_->sumInfeasibilities();
		if (numberThrownOut||
			(sumInfeasibility>1.0e7&&sumInfeasibility>100.0*lastSumInfeasibility
			 &&factorization_->pivotTolerance()<0.11)||(largestPrimalError_>1.0e10&&largestDualError_>1.0e10)) {
				problemStatus_=tentativeStatus;
				doFactorization=true;
				if (numberPivots) {
					// go back
					numberThrownOut=-1;
					// trouble - restore solution
					CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
					CoinMemcpyN(savedSolution_+numberColumns_ ,
								numberRows_,rowActivityWork_);
					CoinMemcpyN(savedSolution_ ,
								numberColumns_,columnActivityWork_);
					// restore extra stuff
					matrix_->generalExpanded(this,6,dummy);
					forceFactorization_=1; // a bit drastic but ..
					// Go to safe
					factorization_->pivotTolerance(0.99);
					pivotRow_=-1; // say no weights update
					changeMade_++; // say change made
					if (numberPivots==1) {
						// throw out something
						if (sequenceIn_>=0&&getStatus(sequenceIn_)!=basic) {
							setFlagged(sequenceIn_);
						} else if (sequenceOut_>=0&&getStatus(sequenceOut_)!=basic) {
							setFlagged(sequenceOut_);
						}
					}
					numberPivots=0;
				}
			}
	}

	// Double check reduced costs if no action
	if (progress->lastIterationNumber(0)==numberIterations_) {
		if (primalColumnPivot_->looksOptimal()) {
			numberDualInfeasibilities_ = 0;
			sumDualInfeasibilities_ = 0.0;
		}
	}
	// If in primal and small dj give up
	if ((specialOptions_&1024)!=0&&!numberPrimalInfeasibilities_&&numberDualInfeasibilities_) {
		double average = sumDualInfeasibilities_/(static_cast<double> (numberDualInfeasibilities_));
		if (numberIterations_>300&&average<1.0e-4) {
			numberDualInfeasibilities_ = 0;
			sumDualInfeasibilities_ = 0.0;
		}
	}

	// Check if looping
	int loop;
	if (type!=2&&!ifValuesPass)
		loop = progress->looping();
	else
		loop=-1;
	if (loop>=0) {
		if (!problemStatus_) {
			// declaring victory
			numberPrimalInfeasibilities_ = 0;
			sumPrimalInfeasibilities_ = 0.0;
		} else {
			problemStatus_ = loop; //exit if in loop
			problemStatus_ = 10; // instead - try other algorithm
			numberPrimalInfeasibilities_ = nonLinearCost_->numberInfeasibilities();
		}
		problemStatus_ = 10; // instead - try other algorithm
		return ;
	} else if (loop<-1) {
		// Is it time for drastic measures
		if (nonLinearCost_->numberInfeasibilities()&&progress->badTimes()>5&&
			progress->oddState()<10&&progress->oddState()>=0) {
			progress->newOddState();
			nonLinearCost_->zapCosts();
		}
		// something may have changed
		gutsOfSolution(NULL,NULL,ifValuesPass!=0);
	}
	// If progress then reset costs
	if (loop==-1&&!nonLinearCost_->numberInfeasibilities()&&progress->oddState()<0) {
		createRim(4,false); // costs back
		delete nonLinearCost_;
		nonLinearCost_ = new ClpNonLinearCost(this);
		progress->endOddState();
		gutsOfSolution(NULL,NULL,ifValuesPass!=0);
	}
	// Flag to say whether to go to dual to clean up
	bool goToDual=false;
	// really for free variables in
	//if((progressFlag_&2)!=0)
	//problemStatus_=-1;;
	progressFlag_ = 0; //reset progress flag

	handler_->message(CLP_SIMPLEX_STATUS,messages_)
    <<numberIterations_<<nonLinearCost_->feasibleReportCost();
	handler_->printing(nonLinearCost_->numberInfeasibilities()>0)
    <<nonLinearCost_->sumInfeasibilities()<<nonLinearCost_->numberInfeasibilities();
	handler_->printing(sumDualInfeasibilities_>0.0)
    <<sumDualInfeasibilities_<<numberDualInfeasibilities_;
	handler_->printing(numberDualInfeasibilitiesWithoutFree_
					   <numberDualInfeasibilities_)
	<<numberDualInfeasibilitiesWithoutFree_;
	handler_->message()<<CoinMessageEol;
	if (!primalFeasible()) {
		nonLinearCost_->checkInfeasibilities(primalTolerance_);
		gutsOfSolution(NULL,NULL,ifValuesPass!=0);
		nonLinearCost_->checkInfeasibilities(primalTolerance_);
	}
	if (nonLinearCost_->numberInfeasibilities()>0&&!progress->initialWeight_&&!ifValuesPass&&infeasibilityCost_==1.0e10) {
		// first time infeasible - start up weight computation
		double * oldDj = dj_;
		double * oldCost = cost_;
		int numberRows2 = numberRows_+numberExtraRows_;
		int numberTotal = numberRows2+numberColumns_;
		dj_ = new double[numberTotal];
		cost_ = new double[numberTotal];
		reducedCostWork_ = dj_;
		rowReducedCost_ = dj_+numberColumns_;
		objectiveWork_ = cost_;
		rowObjectiveWork_ = cost_+numberColumns_;
		double direction = optimizationDirection_*objectiveScale_;
		const double * obj = objective();
		memset(rowObjectiveWork_,0,numberRows_*sizeof(double));
		int iSequence;
		if (columnScale_)
			for (iSequence=0;iSequence<numberColumns_;iSequence++)
				cost_[iSequence] = obj[iSequence]*direction*columnScale_[iSequence];
		else
			for (iSequence=0;iSequence<numberColumns_;iSequence++)
				cost_[iSequence] = obj[iSequence]*direction;
		computeDuals(NULL);
		int numberSame=0;
		int numberDifferent=0;
		int numberZero=0;
		int numberFreeSame=0;
		int numberFreeDifferent=0;
		int numberFreeZero=0;
		int n=0;
		for (iSequence=0;iSequence<numberTotal;iSequence++) {
			if (getStatus(iSequence) != basic&&!flagged(iSequence)) {
				// not basic
				double distanceUp = upper_[iSequence]-solution_[iSequence];
				double distanceDown = solution_[iSequence]-lower_[iSequence];
				double feasibleDj = dj_[iSequence];
				double infeasibleDj = oldDj[iSequence]-feasibleDj;
				double value = feasibleDj*infeasibleDj;
				if (distanceUp>primalTolerance_) {
					// Check if "free"
					if (distanceDown>primalTolerance_) {
						// free
						if (value>dualTolerance_) {
							numberFreeSame++;
						} else if(value<-dualTolerance_) {
							numberFreeDifferent++;
							dj_[n++] = feasibleDj/infeasibleDj;
						} else {
							numberFreeZero++;
						}
					} else {
						// should not be negative
						if (value>dualTolerance_) {
							numberSame++;
						} else if(value<-dualTolerance_) {
							numberDifferent++;
							dj_[n++] = feasibleDj/infeasibleDj;
						} else {
							numberZero++;
						}
					}
				} else if (distanceDown>primalTolerance_) {
					// should not be positive
					if (value>dualTolerance_) {
						numberSame++;
					} else if(value<-dualTolerance_) {
						numberDifferent++;
						dj_[n++] = feasibleDj/infeasibleDj;
					} else {
						numberZero++;
					}
				}
			}
			progress->initialWeight_=-1.0;
		}
		//printf("XXXX %d same, %d different, %d zero, -- free %d %d %d\n",
		//   numberSame,numberDifferent,numberZero,
		//   numberFreeSame,numberFreeDifferent,numberFreeZero);
		// we want most to be same
		if (n) {
			double most = 0.95;
			std::sort(dj_,dj_+n);
			int which = static_cast<int> ((1.0-most)*static_cast<double> (n));
			double take = -dj_[which]*infeasibilityCost_;
			//printf("XXXXZ inf cost %g take %g (range %g %g)\n",infeasibilityCost_,take,-dj_[0]*infeasibilityCost_,-dj_[n-1]*infeasibilityCost_);
			take = -dj_[0]*infeasibilityCost_;
			infeasibilityCost_ = std::min(std::max(1000.0*take,1.0e8),1.0000001e10);;
			//printf("XXXX increasing weight to %g\n",infeasibilityCost_);
		}
		delete [] dj_;
		delete [] cost_;
		dj_= oldDj;
		cost_ = oldCost;
		reducedCostWork_ = dj_;
		rowReducedCost_ = dj_+numberColumns_;
		objectiveWork_ = cost_;
		rowObjectiveWork_ = cost_+numberColumns_;
		if (n)
			gutsOfSolution(NULL,NULL,ifValuesPass!=0);
	}
	double trueInfeasibility =nonLinearCost_->sumInfeasibilities();
	if (!nonLinearCost_->numberInfeasibilities()&&infeasibilityCost_==1.0e10&&!ifValuesPass&&true) {
		// relax if default
		infeasibilityCost_ = std::min(std::max(100.0*sumDualInfeasibilities_,1.0e8),1.00000001e10);
		// reset looping criterion
		progress->reset();
		trueInfeasibility = 1.123456e10;
	}
	if (trueInfeasibility>1.0) {
		// If infeasibility going up may change weights
		double testValue = trueInfeasibility-1.0e-4*(10.0+trueInfeasibility);
		double lastInf = progress->lastInfeasibility(1);
		double lastInf3 = progress->lastInfeasibility(3);
		double thisObj = progress->lastObjective(0);
		double thisInf = progress->lastInfeasibility(0);
		thisObj += infeasibilityCost_*2.0*thisInf;
		double lastObj = progress->lastObjective(1);
		lastObj += infeasibilityCost_*2.0*lastInf;
		double lastObj3 = progress->lastObjective(3);
		lastObj3 += infeasibilityCost_*2.0*lastInf3;
		if (lastObj<thisObj-1.0e-5*std::max(fabs(thisObj),fabs(lastObj))-1.0e-7
			&&firstFree_<0) {
			if (handler_->logLevel()==63)
				printf("lastobj %g this %g force %d ",lastObj,thisObj,forceFactorization_);
			int maxFactor = factorization_->maximumPivots();
			if (maxFactor>10) {
				if (forceFactorization_<0)
					forceFactorization_= maxFactor;
				forceFactorization_ = std::max(1,(forceFactorization_>>2));
				if (handler_->logLevel()==63)
					printf("Reducing factorization frequency to %d\n",forceFactorization_);
			}
		} else if (lastObj3<thisObj-1.0e-5*std::max(fabs(thisObj),fabs(lastObj3))-1.0e-7
				   &&firstFree_<0) {
			if (handler_->logLevel()==63)
				printf("lastobj3 %g this3 %g `force %d ",lastObj3,thisObj,forceFactorization_);
			int maxFactor = factorization_->maximumPivots();
			if (maxFactor>10) {
				if (forceFactorization_<0)
					forceFactorization_= maxFactor;
				forceFactorization_ = std::max(1,(forceFactorization_*2)/3);
				if (handler_->logLevel()==63)
					printf("Reducing factorization frequency to %d\n",forceFactorization_);
			}
		} else if(lastInf<testValue||trueInfeasibility==1.123456e10) {
			if (infeasibilityCost_<1.0e14) {
				infeasibilityCost_ *= 1.5;
				// reset looping criterion
				progress->reset();
				if (handler_->logLevel()==63)
					printf("increasing weight to %g\n",infeasibilityCost_);
				gutsOfSolution(NULL,NULL,ifValuesPass!=0);
			}
		}
	}
	// we may wish to say it is optimal even if infeasible
	bool alwaysOptimal = (specialOptions_&1)!=0;
	// give code benefit of doubt
	if (sumOfRelaxedDualInfeasibilities_ == 0.0&&
		sumOfRelaxedPrimalInfeasibilities_ == 0.0) {
		// say optimal (with these bounds etc)
		numberDualInfeasibilities_ = 0;
		sumDualInfeasibilities_ = 0.0;
		numberPrimalInfeasibilities_ = 0;
		sumPrimalInfeasibilities_ = 0.0;
		// But check if in sprint
		if (originalModel) {
			// Carry on and re-do
			numberDualInfeasibilities_ = -776;
		}
		// But if real primal infeasibilities nonzero carry on
		if (nonLinearCost_->numberInfeasibilities()) {
			// most likely to happen if infeasible
			double relaxedToleranceP=primalTolerance_;
			// we can't really trust infeasibilities if there is primal error
			double error = std::min(1.0e-2,largestPrimalError_);
			// allow tolerance at least slightly bigger than standard
			relaxedToleranceP = relaxedToleranceP +  error;
			int ninfeas = nonLinearCost_->numberInfeasibilities();
			double sum = nonLinearCost_->sumInfeasibilities();
			double average = sum/ static_cast<double> (ninfeas);
#ifdef COIN_DEVELOP
			if (handler_->logLevel()>0)
				printf("nonLinearCost says infeasible %d summing to %g\n",
					   ninfeas,sum);
#endif
			if (average>relaxedToleranceP) {
				sumOfRelaxedPrimalInfeasibilities_ = sum;
				numberPrimalInfeasibilities_ = ninfeas;
				sumPrimalInfeasibilities_ = sum;
#ifdef COIN_DEVELOP
				bool unflagged =
#endif
				unflag();
#ifdef COIN_DEVELOP
				if (unflagged&&handler_->logLevel()>0)
					printf(" - but flagged variables\n");
#endif
			}
		}
	}
	// had ||(type==3&&problemStatus_!=-5) -- ??? why ????
	if ((dualFeasible()||problemStatus_==-4)&&!ifValuesPass) {
		// see if extra helps
		if (nonLinearCost_->numberInfeasibilities()&&
			(nonLinearCost_->sumInfeasibilities()>1.0e-3||sumOfRelaxedPrimalInfeasibilities_)
			&&!alwaysOptimal) {
			//may need infeasiblity cost changed
			// we can see if we can construct a ray
			// make up a new objective
			double saveWeight = infeasibilityCost_;
			// save nonlinear cost as we are going to switch off costs
			ClpNonLinearCost * nonLinear = nonLinearCost_;
			// do twice to make sure Primal solution has settled
			// put non-basics to bounds in case tolerance moved
			// put back original costs
			createRim(4);
			nonLinearCost_->checkInfeasibilities(0.0);
			gutsOfSolution(NULL,NULL,ifValuesPass!=0);

			infeasibilityCost_=1.0e100;
			// put back original costs
			createRim(4);
			nonLinearCost_->checkInfeasibilities(primalTolerance_);
			// may have fixed infeasibilities - double check
			if (nonLinearCost_->numberInfeasibilities()==0) {
				// carry on
				problemStatus_ = -1;
				infeasibilityCost_=saveWeight;
				nonLinearCost_->checkInfeasibilities(primalTolerance_);
			} else {
				nonLinearCost_=NULL;
				// scale
				int i;
				for (i=0;i<numberRows_+numberColumns_;i++)
					cost_[i] *= 1.0e-95;
				gutsOfSolution(NULL,NULL,ifValuesPass!=0);
				nonLinearCost_=nonLinear;
				infeasibilityCost_=saveWeight;
				if ((infeasibilityCost_>=1.0e18||
					 numberDualInfeasibilities_==0)&&perturbation_==101) {
					goToDual=unPerturb(); // stop any further perturbation
					if (nonLinearCost_->sumInfeasibilities()>1.0e-1)
						goToDual=false;
					nonLinearCost_->checkInfeasibilities(primalTolerance_);
					numberDualInfeasibilities_=1; // carry on
					problemStatus_=-1;
				} else if (numberDualInfeasibilities_==0&&largestDualError_>1.0e-2) {
					goToDual=true;
					factorization_->pivotTolerance(std::max(0.9,factorization_->pivotTolerance()));
				}
				if (!goToDual) {
					if (infeasibilityCost_>=1.0e20||
						numberDualInfeasibilities_==0) {
						// we are infeasible - use as ray
						delete [] ray_;
						ray_ = new double [numberRows_];
						CoinMemcpyN(dual_,numberRows_,ray_);
						// and get feasible duals
						infeasibilityCost_=0.0;
						createRim(4);
						nonLinearCost_->checkInfeasibilities(primalTolerance_);
						gutsOfSolution(NULL,NULL,ifValuesPass!=0);
						// so will exit
						infeasibilityCost_=1.0e30;
						// reset infeasibilities
						sumPrimalInfeasibilities_=nonLinearCost_->sumInfeasibilities();;
						numberPrimalInfeasibilities_=
						nonLinearCost_->numberInfeasibilities();
					}
					if (infeasibilityCost_<1.0e20) {
						infeasibilityCost_ *= 5.0;
						// reset looping criterion
						progress->reset();
						changeMade_++; // say change made
						handler_->message(CLP_PRIMAL_WEIGHT,messages_)
						<<infeasibilityCost_
						<<CoinMessageEol;
						// put back original costs and then check
						createRim(4);
						nonLinearCost_->checkInfeasibilities(0.0);
						gutsOfSolution(NULL,NULL,ifValuesPass!=0);
						problemStatus_=-1; //continue
						goToDual=false;
					} else {
						// say infeasible
						problemStatus_ = 1;
					}
				}
			}
		} else {
			// may be optimal
			if (perturbation_==101) {
				goToDual=unPerturb(); // stop any further perturbation
				if (numberRows_>20000&&!numberTimesOptimal_)
					goToDual=0; // Better to carry on a bit longer
				lastCleaned=-1; // carry on
			}
			bool unflagged = (unflag()!=0);
			if ( lastCleaned!=numberIterations_||unflagged) {
				handler_->message(CLP_PRIMAL_OPTIMAL,messages_)
				<<primalTolerance_
				<<CoinMessageEol;
				if (numberTimesOptimal_<4) {
					numberTimesOptimal_++;
					changeMade_++; // say change made
					if (numberTimesOptimal_==1) {
						// better to have small tolerance even if slower
						factorization_->zeroTolerance(std::min(factorization_->zeroTolerance(),1.0e-15));
					}
					lastCleaned=numberIterations_;
					if (primalTolerance_!=dblParam_[ClpPrimalTolerance])
						handler_->message(CLP_PRIMAL_ORIGINAL,messages_)
						<<CoinMessageEol;
					double oldTolerance = primalTolerance_;
					primalTolerance_=dblParam_[ClpPrimalTolerance];
#if 0
					double * xcost = new double[numberRows_+numberColumns_];
					double * xlower = new double[numberRows_+numberColumns_];
					double * xupper = new double[numberRows_+numberColumns_];
					double * xdj = new double[numberRows_+numberColumns_];
					double * xsolution = new double[numberRows_+numberColumns_];
					CoinMemcpyN(cost_,(numberRows_+numberColumns_),xcost);
					CoinMemcpyN(lower_,(numberRows_+numberColumns_),xlower);
					CoinMemcpyN(upper_,(numberRows_+numberColumns_),xupper);
					CoinMemcpyN(dj_,(numberRows_+numberColumns_),xdj);
					CoinMemcpyN(solution_,(numberRows_+numberColumns_),xsolution);
#endif
					// put back original costs and then check
					createRim(4);
					nonLinearCost_->checkInfeasibilities(oldTolerance);
#if 0
					int i;
					for (i=0;i<numberRows_+numberColumns_;i++) {
						if (cost_[i]!=xcost[i])
							printf("** %d old cost %g new %g sol %g\n",
								   i,xcost[i],cost_[i],solution_[i]);
						if (lower_[i]!=xlower[i])
							printf("** %d old lower %g new %g sol %g\n",
								   i,xlower[i],lower_[i],solution_[i]);
						if (upper_[i]!=xupper[i])
							printf("** %d old upper %g new %g sol %g\n",
								   i,xupper[i],upper_[i],solution_[i]);
						if (dj_[i]!=xdj[i])
							printf("** %d old dj %g new %g sol %g\n",
								   i,xdj[i],dj_[i],solution_[i]);
						if (solution_[i]!=xsolution[i])
							printf("** %d old solution %g new %g sol %g\n",
								   i,xsolution[i],solution_[i],solution_[i]);
					}
					delete [] xcost;
					delete [] xupper;
					delete [] xlower;
					delete [] xdj;
					delete [] xsolution;
#endif
					gutsOfSolution(NULL,NULL,ifValuesPass!=0);
					if (sumOfRelaxedDualInfeasibilities_ == 0.0&&
						sumOfRelaxedPrimalInfeasibilities_ == 0.0) {
						// say optimal (with these bounds etc)
						numberDualInfeasibilities_ = 0;
						sumDualInfeasibilities_ = 0.0;
						numberPrimalInfeasibilities_ = 0;
						sumPrimalInfeasibilities_ = 0.0;
					}
					if (dualFeasible()&&!nonLinearCost_->numberInfeasibilities()&&lastCleaned>=0)
						problemStatus_=0;
					else
						problemStatus_ = -1;
				} else {
					problemStatus_=0; // optimal
					if (lastCleaned<numberIterations_) {
						handler_->message(CLP_SIMPLEX_GIVINGUP,messages_)
						<<CoinMessageEol;
					}
				}
			} else {
				if (!alwaysOptimal||!sumOfRelaxedPrimalInfeasibilities_)
					problemStatus_=0; // optimal
				else
					problemStatus_=1; // infeasible
			}
		}
	} else {
		// see if looks unbounded
		if (problemStatus_==-5) {
			if (nonLinearCost_->numberInfeasibilities()) {
				if (infeasibilityCost_>1.0e18&&perturbation_==101) {
					// back off weight
					infeasibilityCost_ = 1.0e13;
					// reset looping criterion
					progress->reset();
					unPerturb(); // stop any further perturbation
				}
				//we need infeasiblity cost changed
				if (infeasibilityCost_<1.0e20) {
					infeasibilityCost_ *= 5.0;
					// reset looping criterion
					progress->reset();
					changeMade_++; // say change made
					handler_->message(CLP_PRIMAL_WEIGHT,messages_)
					<<infeasibilityCost_
					<<CoinMessageEol;
					// put back original costs and then check
					createRim(4);
					gutsOfSolution(NULL,NULL,ifValuesPass!=0);
					problemStatus_=-1; //continue
				} else {
					// say infeasible
					problemStatus_ = 1;
					// we are infeasible - use as ray
					delete [] ray_;
					ray_ = new double [numberRows_];
					CoinMemcpyN(dual_,numberRows_,ray_);
				}
			} else {
				// say unbounded
				problemStatus_ = 2;
			}
		} else {
			// carry on
			problemStatus_ = -1;
			if(type==3&&problemStatus_!=-5) {
				//bool unflagged =
				unflag();
				if (sumDualInfeasibilities_<1.0e-3||
					(sumDualInfeasibilities_/static_cast<double> (numberDualInfeasibilities_))<1.0e-5||
					progress->lastIterationNumber(0)==numberIterations_) {
					if (!numberPrimalInfeasibilities_) {
						if (numberTimesOptimal_<4) {
							numberTimesOptimal_++;
							changeMade_++; // say change made
						} else {
							problemStatus_=0;
							secondaryStatus_=5;
						}
					}
				}
			}
		}
	}
	if (problemStatus_==0) {
		double objVal = nonLinearCost_->feasibleCost();
		double tol = 1.0e-10*std::max(fabs(objVal),fabs(objectiveValue_))+1.0e-8;
		if (fabs(objVal-objectiveValue_)>tol) {
#ifdef COIN_DEVELOP
			if (handler_->logLevel()>0)
				printf("nonLinearCost has feasible obj of %g, objectiveValue_ is %g\n",
					   objVal,objectiveValue_);
#endif
			objectiveValue_ = objVal;
		}
	}
	// save extra stuff
	matrix_->generalExpanded(this,5,dummy);
	if (type==0||type==1) {
		if (type!=1||!saveStatus_) {
			// create save arrays
			delete [] saveStatus_;
			delete [] savedSolution_;
			saveStatus_ = new unsigned char [numberRows_+numberColumns_];
			savedSolution_ = new double [numberRows_+numberColumns_];
		}
		// save arrays
		CoinMemcpyN(status_,numberColumns_+numberRows_,saveStatus_);
		CoinMemcpyN(rowActivityWork_,
					numberRows_,savedSolution_+numberColumns_);
		CoinMemcpyN(columnActivityWork_,numberColumns_,savedSolution_);
	}
	// see if in Cbc etc
	bool inCbcOrOther = (specialOptions_&0x03000000)!=0;
	bool disaster=false;
	if (disasterArea_&&inCbcOrOther&&disasterArea_->check()) {
		disasterArea_->saveInfo();
		disaster=true;
	}
	if (disaster)
		problemStatus_=3;
	if (problemStatus_<0&&!changeMade_) {
		problemStatus_=4; // unknown
	}
	lastGoodIteration_ = numberIterations_;
	if (numberIterations_>lastBadIteration_+100)
		moreSpecialOptions_ &= ~16; // clear check accuracy flag
	if (goToDual)
		problemStatus_=10; // try dual
	// make sure first free monotonic
	if (firstFree_>=0&&saveFirstFree>=0) {
		firstFree_=saveFirstFree;
		nextSuperBasic(1,NULL);
	}
	if (doFactorization) {
		// restore weights (if saved) - also recompute infeasibility list
		if (tentativeStatus>-3)
			primalColumnPivot_->saveWeights(this,(type <2) ? 2 : 4);
		else
			primalColumnPivot_->saveWeights(this,3);
		if (saveThreshold) {
			// use default at present
			factorization_->sparseThreshold(0);
			factorization_->goSparse();
		}
	}
	// Allow matrices to be sorted etc
	int fake=-999; // signal sort
	matrix_->correctSequence(this,fake,fake);
}

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void
IClpSimplexPrimal::primalRow(CoinIndexedVector * rowArray,
								   CoinIndexedVector * rhsArray,
								   CoinIndexedVector * spareArray,
								   CoinIndexedVector * spareArray2,
								   int valuesPass)
{
	DantzigPrimalRow(rowArray, rhsArray, spareArray, spareArray2, valuesPass);
	//import_CyClpSimplex();
	//CyPostPrimalRow(static_cast<IClpSimplex *>(this));
}
/*
 Row array has pivot column
 This chooses pivot row.
 For speed, we may need to go to a bucket approach when many
 variables go through bounds
 On exit rhsArray will have changes in costs of basic variables
 */
void
IClpSimplexPrimal::DantzigPrimalRow(CoinIndexedVector * rowArray,
								   CoinIndexedVector * rhsArray,
								   CoinIndexedVector * spareArray,
								   CoinIndexedVector * spareArray2,
								   int valuesPass)
{
	double saveDj = dualIn_;
	if (valuesPass&&objective_->type()<2) {
		dualIn_ = cost_[sequenceIn_];

		double * work=rowArray->denseVector();
		int number=rowArray->getNumElements();
		int * which=rowArray->getIndices();

		int iIndex;
		for (iIndex=0;iIndex<number;iIndex++) {

			int iRow = which[iIndex];
			double alpha = work[iIndex];
			int iPivot=pivotVariable_[iRow];
			dualIn_ -= alpha*cost_[iPivot];
		}
		// determine direction here
		if (dualIn_<-dualTolerance_) {
			directionIn_=1;
		} else if (dualIn_>dualTolerance_) {
			directionIn_=-1;
		} else {
			// towards nearest bound
			if (valueIn_-lowerIn_<upperIn_-valueIn_) {
				directionIn_=-1;
				dualIn_=dualTolerance_;
			} else {
				directionIn_=1;
				dualIn_=-dualTolerance_;
			}
		}
	}

	// sequence stays as row number until end
	pivotRow_=-1;
	int numberRemaining=0;

	double totalThru=0.0; // for when variables flip
	// Allow first few iterations to take tiny
	double acceptablePivot=1.0e-1*acceptablePivot_;
	if (numberIterations_>100)
		acceptablePivot=acceptablePivot_;
	if (factorization_->pivots()>10)
		acceptablePivot=1.0e+3*acceptablePivot_; // if we have iterated be more strict
	else if (factorization_->pivots()>5)
		acceptablePivot=1.0e+2*acceptablePivot_; // if we have iterated be slightly more strict
	else if (factorization_->pivots())
		acceptablePivot=acceptablePivot_; // relax
	double bestEverPivot=acceptablePivot;
	int lastPivotRow = -1;
	double lastPivot=0.0;
	double lastTheta=1.0e50;

	// use spareArrays to put ones looked at in
	// First one is list of candidates
	// We could compress if we really know we won't need any more
	// Second array has current set of pivot candidates
	// with a backup list saved in double * part of indexed vector

	// pivot elements
	double * spare;
	// indices
	int * index;
	spareArray->clear();
	spare = spareArray->denseVector();
	index = spareArray->getIndices();

	// we also need somewhere for effective rhs
	double * rhs=rhsArray->denseVector();
	// and we can use indices to point to alpha
	// that way we can store fabs(alpha)
	int * indexPoint = rhsArray->getIndices();
	//int numberFlip=0; // Those which may change if flips

	/*
	 First we get a list of possible pivots.  We can also see if the
	 problem looks unbounded.

	 At first we increase theta and see what happens.  We start
	 theta at a reasonable guess.  If in right area then we do bit by bit.
	 We save possible pivot candidates

	 */

	// do first pass to get possibles
	// We can also see if unbounded

	double * work=rowArray->denseVector();
	int number=rowArray->getNumElements();
	int * which=rowArray->getIndices();

	// we need to swap sign if coming in from ub
	double way = directionIn_;
	double maximumMovement;
	if (way>0.0)
		maximumMovement = std::min(1.0e30,upperIn_-valueIn_);
	else
		maximumMovement = std::min(1.0e30,valueIn_-lowerIn_);

	double averageTheta = nonLinearCost_->averageTheta();
	double tentativeTheta = std::min(10.0*averageTheta,maximumMovement);
	double upperTheta = maximumMovement;
	if (tentativeTheta>0.5*maximumMovement)
		tentativeTheta=maximumMovement;
	bool thetaAtMaximum=tentativeTheta==maximumMovement;
	// In case tiny bounds increase
	if (maximumMovement<1.0)
		tentativeTheta *= 1.1;
	double dualCheck = fabs(dualIn_);
	// but make a bit more pessimistic
	dualCheck=std::max(dualCheck-100.0*dualTolerance_,0.99*dualCheck);

	int iIndex;
	int pivotOne=-1;
	//#define CLP_DEBUG
#ifdef CLP_DEBUG
	if (numberIterations_==-3839||numberIterations_==-3840) {
		double dj=cost_[sequenceIn_];
		printf("cost in on %d is %g, dual in %g\n",sequenceIn_,dj,dualIn_);
		for (iIndex=0;iIndex<number;iIndex++) {

			int iRow = which[iIndex];
			double alpha = work[iIndex];
			int iPivot=pivotVariable_[iRow];
			dj -= alpha*cost_[iPivot];
			printf("row %d var %d current %g %g %g, alpha %g so sol => %g (cost %g, dj %g)\n",
				   iRow,iPivot,lower_[iPivot],solution_[iPivot],upper_[iPivot],
				   alpha, solution_[iPivot]-1.0e9*alpha,cost_[iPivot],dj);
		}
	}
#endif
	while (true) {
		pivotOne=-1;
		totalThru=0.0;
		// We also re-compute reduced cost
		numberRemaining=0;
		dualIn_ = cost_[sequenceIn_];
#ifndef NDEBUG
		double tolerance = primalTolerance_*1.002;
#endif
		for (iIndex=0;iIndex<number;iIndex++) {

			int iRow = which[iIndex];
			double alpha = work[iIndex];
			int iPivot=pivotVariable_[iRow];
			if (cost_[iPivot])
				dualIn_ -= alpha*cost_[iPivot];
			alpha *= way;
			double oldValue = solution_[iPivot];
			// get where in bound sequence
			// note that after this alpha is actually fabs(alpha)
			bool possible;
			// do computation same way as later on in primal
			if (alpha>0.0) {
				// basic variable going towards lower bound
				double bound = lower_[iPivot];
				// must be exactly same as when used
				double change = tentativeTheta*alpha;
				possible = (oldValue-change)<=bound+primalTolerance_;
				oldValue -= bound;
			} else {
				// basic variable going towards upper bound
				double bound = upper_[iPivot];
				// must be exactly same as when used
				double change = tentativeTheta*alpha;
				possible = (oldValue-change)>=bound-primalTolerance_;
				oldValue = bound-oldValue;
				alpha = - alpha;
			}
			double value;
			assert (oldValue>=-tolerance);
			if (possible) {
				value=oldValue-upperTheta*alpha;
				if (value<-primalTolerance_&&alpha>=acceptablePivot) {
					upperTheta = (oldValue+primalTolerance_)/alpha;
					pivotOne=numberRemaining;
				}
				// add to list
				spare[numberRemaining]=alpha;
				rhs[numberRemaining]=oldValue;
				indexPoint[numberRemaining]=iIndex;
				index[numberRemaining++]=iRow;
				totalThru += alpha;
				setActive(iRow);
				//} else if (value<primalTolerance_*1.002) {
				// May change if is a flip
				//indexRhs[numberFlip++]=iRow;
			}
		}
		if (upperTheta<maximumMovement&&totalThru*infeasibilityCost_>=1.0001*dualCheck) {
			// Can pivot here
			break;
		} else if (!thetaAtMaximum) {
			//printf("Going round with average theta of %g\n",averageTheta);
			tentativeTheta=maximumMovement;
			thetaAtMaximum=true; // seems to be odd compiler error
		} else {
			break;
		}
	}
	totalThru=0.0;

	theta_=maximumMovement;

	bool goBackOne = false;
	if (objective_->type()>1)
		dualIn_=saveDj;

	//printf("%d remain out of %d\n",numberRemaining,number);
	int iTry=0;
#define MAXTRY 1000
	if (numberRemaining&&upperTheta<maximumMovement) {
		// First check if previously chosen one will work
		if (pivotOne>=0&&0) {
			double thruCost = infeasibilityCost_*spare[pivotOne];
			if (thruCost>=0.99*fabs(dualIn_))
				printf("Could pivot on %d as change %g dj %g\n",
					   index[pivotOne],thruCost,dualIn_);
			double alpha = spare[pivotOne];
			double oldValue = rhs[pivotOne];
			theta_ = oldValue/alpha;
			pivotRow_=pivotOne;
			// Stop loop
			iTry=MAXTRY;
		}

		// first get ratio with tolerance
		for ( ;iTry<MAXTRY;iTry++) {

			upperTheta=maximumMovement;
			int iBest=-1;
			for (iIndex=0;iIndex<numberRemaining;iIndex++) {

				double alpha = spare[iIndex];
				double oldValue = rhs[iIndex];
				double value = oldValue-upperTheta*alpha;

				if (value<-primalTolerance_ && alpha>=acceptablePivot) {
					upperTheta = (oldValue+primalTolerance_)/alpha;
					iBest=iIndex; // just in case weird numbers
				}
			}

			// now look at best in this lot
			// But also see how infeasible small pivots will make
			double sumInfeasibilities=0.0;
			double bestPivot=acceptablePivot;
			pivotRow_=-1;
			for (iIndex=0;iIndex<numberRemaining;iIndex++) {

				int iRow = index[iIndex];
				double alpha = spare[iIndex];
				double oldValue = rhs[iIndex];
				double value = oldValue-upperTheta*alpha;

				if (value<=0||iBest==iIndex) {
					// how much would it cost to go thru and modify bound
					double trueAlpha=way*work[indexPoint[iIndex]];
					totalThru += nonLinearCost_->changeInCost(pivotVariable_[iRow],trueAlpha,rhs[iIndex]);
					setActive(iRow);
					if (alpha>bestPivot) {
						bestPivot=alpha;
						theta_ = oldValue/bestPivot;
						pivotRow_=iIndex;
					} else if (alpha<acceptablePivot) {
						if (value<-primalTolerance_)
							sumInfeasibilities += -value-primalTolerance_;
					}
				}
			}
			if (bestPivot<0.1*bestEverPivot&&
				bestEverPivot>1.0e-6&& bestPivot<1.0e-3) {
				// back to previous one
				goBackOne = true;
				break;
			} else if (pivotRow_==-1&&upperTheta>largeValue_) {
				if (lastPivot>acceptablePivot) {
					// back to previous one
					goBackOne = true;
				} else {
					// can only get here if all pivots so far too small
				}
				break;
			} else if (totalThru>=dualCheck) {
				if (sumInfeasibilities>primalTolerance_&&!nonLinearCost_->numberInfeasibilities()) {
					// Looks a bad choice
					if (lastPivot>acceptablePivot) {
						goBackOne=true;
					} else {
						// say no good
						dualIn_=0.0;
					}
				}
				break; // no point trying another loop
			} else {
				lastPivotRow=pivotRow_;
				lastTheta = theta_;
				if (bestPivot>bestEverPivot)
					bestEverPivot=bestPivot;
			}
		}
		// can get here without pivotRow_ set but with lastPivotRow
		if (goBackOne||(pivotRow_<0&&lastPivotRow>=0)) {
			// back to previous one
			pivotRow_=lastPivotRow;
			theta_ = lastTheta;
		}
	} else if (pivotRow_<0&&maximumMovement>1.0e20) {
		// looks unbounded
		valueOut_=COIN_DBL_MAX; // say odd
		if (nonLinearCost_->numberInfeasibilities()) {
			// but infeasible??
			// move variable but don't pivot
			tentativeTheta=1.0e50;
			for (iIndex=0;iIndex<number;iIndex++) {
				int iRow = which[iIndex];
				double alpha = work[iIndex];
				int iPivot=pivotVariable_[iRow];
				alpha *= way;
				double oldValue = solution_[iPivot];
				// get where in bound sequence
				// note that after this alpha is actually fabs(alpha)
				if (alpha>0.0) {
					// basic variable going towards lower bound
					double bound = lower_[iPivot];
					oldValue -= bound;
				} else {
					// basic variable going towards upper bound
					double bound = upper_[iPivot];
					oldValue = bound-oldValue;
					alpha = - alpha;
				}
				if (oldValue-tentativeTheta*alpha<0.0) {
					tentativeTheta = oldValue/alpha;
				}
			}
			// If free in then see if we can get to 0.0
			if (lowerIn_<-1.0e20&&upperIn_>1.0e20) {
				if (dualIn_*valueIn_>0.0) {
					if (fabs(valueIn_)<1.0e-2&&(tentativeTheta<fabs(valueIn_)||tentativeTheta>1.0e20)) {
						tentativeTheta = fabs(valueIn_);
					}
				}
			}
			if (tentativeTheta<1.0e10)
				valueOut_=valueIn_+way*tentativeTheta;
		}
	}
	//if (iTry>50)
	//printf("** %d tries\n",iTry);
	if (pivotRow_>=0) {
		int position=pivotRow_; // position in list
		pivotRow_=index[position];
		alpha_=work[indexPoint[position]];
		// translate to sequence
		sequenceOut_ = pivotVariable_[pivotRow_];
		valueOut_ = solution(sequenceOut_);
		lowerOut_=lower_[sequenceOut_];
		upperOut_=upper_[sequenceOut_];
#define MINIMUMTHETA 1.0e-12
		// Movement should be minimum for anti-degeneracy - unless
		// fixed variable out
		double minimumTheta;
		if (upperOut_>lowerOut_)
			minimumTheta=MINIMUMTHETA;
		else
			minimumTheta=0.0;
		// But can't go infeasible
		double distance;
		if (alpha_*way>0.0)
			distance=valueOut_-lowerOut_;
		else
			distance=upperOut_-valueOut_;
		if (distance-minimumTheta*fabs(alpha_)<-primalTolerance_)
			minimumTheta = std::max(0.0,(distance+0.5*primalTolerance_)/fabs(alpha_));
		// will we need to increase tolerance
		//#define CLP_DEBUG
		double largestInfeasibility = primalTolerance_;
		if (theta_<minimumTheta&&(specialOptions_&4)==0&&!valuesPass) {
			theta_=minimumTheta;
			for (iIndex=0;iIndex<numberRemaining-numberRemaining;iIndex++) {
				largestInfeasibility = std::max(largestInfeasibility,
											   -(rhs[iIndex]-spare[iIndex]*theta_));
			}
			//#define CLP_DEBUG
#ifdef CLP_DEBUG
			if (largestInfeasibility>primalTolerance_&&(handler_->logLevel()&32)>-1)
				printf("Primal tolerance increased from %g to %g\n",
					   primalTolerance_,largestInfeasibility);
#endif
			//#undef CLP_DEBUG
			primalTolerance_ = std::max(primalTolerance_,largestInfeasibility);
		}
		// Need to look at all in some cases
		if (theta_>tentativeTheta) {
			for (iIndex=0;iIndex<number;iIndex++)
				setActive(which[iIndex]);
		}
		if (way<0.0)
			theta_ = - theta_;
		double newValue = valueOut_ - theta_*alpha_;
		// If  4 bit set - Force outgoing variables to exact bound (primal)
		if (alpha_*way<0.0) {
			directionOut_=-1;      // to upper bound
			if (fabs(theta_)>1.0e-6||(specialOptions_&4)!=0) {
				upperOut_ = nonLinearCost_->nearest(sequenceOut_,newValue);
			} else {
				upperOut_ = newValue;
			}
		} else {
			directionOut_=1;      // to lower bound
			if (fabs(theta_)>1.0e-6||(specialOptions_&4)!=0) {
				lowerOut_ = nonLinearCost_->nearest(sequenceOut_,newValue);
			} else {
				lowerOut_ = newValue;
			}
		}
		dualOut_ = reducedCost(sequenceOut_);
	} else if (maximumMovement<1.0e20) {
		// flip
		pivotRow_ = -2; // so we can tell its a flip
		sequenceOut_ = sequenceIn_;
		valueOut_ = valueIn_;
		dualOut_ = dualIn_;
		lowerOut_ = lowerIn_;
		upperOut_ = upperIn_;
		alpha_ = 0.0;
		if (way<0.0) {
			directionOut_=1;      // to lower bound
			theta_ = lowerOut_ - valueOut_;
		} else {
			directionOut_=-1;      // to upper bound
			theta_ = upperOut_ - valueOut_;
		}
	}

	double theta1 = std::max(theta_,1.0e-12);
	double theta2 = numberIterations_*nonLinearCost_->averageTheta();
	// Set average theta
	nonLinearCost_->setAverageTheta((theta1+theta2)/(static_cast<double> (numberIterations_+1)));
	//if (numberIterations_%1000==0)
	//printf("average theta is %g\n",nonLinearCost_->averageTheta());

	// clear arrays

	CoinZeroN(spare,numberRemaining);

	// put back original bounds etc
	CoinMemcpyN(index,numberRemaining,rhsArray->getIndices());
	rhsArray->setNumElements(numberRemaining);
	rhsArray->setPacked();
	nonLinearCost_->goBackAll(rhsArray);
	rhsArray->clear();

}
/*
 Chooses primal pivot column
 updateArray has cost updates (also use pivotRow_ from last iteration)
 Would be faster with separate region to scan
 and will have this (with square of infeasibility) when steepest
 For easy problems we can just choose one of the first columns we look at
 */
void
IClpSimplexPrimal::primalColumn(CoinIndexedVector * updates,
									  CoinIndexedVector * spareRow1,
									  CoinIndexedVector * spareRow2,
									  CoinIndexedVector * spareColumn1,
									  CoinIndexedVector * spareColumn2)
{

	ClpMatrixBase * saveMatrix = matrix_;
	double * saveRowScale = rowScale_;
	if (scaledMatrix_) {
		rowScale_=NULL;
		matrix_ = scaledMatrix_;
	}
	sequenceIn_ = primalColumnPivot_->pivotColumn(updates,spareRow1,
												  spareRow2,spareColumn1,
												  spareColumn2);
	if (scaledMatrix_) {
		matrix_ = saveMatrix;
		rowScale_ = saveRowScale;
	}
	if (sequenceIn_>=0) {
		valueIn_=solution_[sequenceIn_];
		dualIn_=dj_[sequenceIn_];
		if (nonLinearCost_->lookBothWays()) {
			// double check
			IClpSimplex::Status status = getStatus(sequenceIn_);

			switch(status) {
				case IClpSimplex::atUpperBound:
					if (dualIn_<0.0) {
						// move to other side
						printf("For %d U (%g, %g, %g) dj changed from %g",
							   sequenceIn_,lower_[sequenceIn_],solution_[sequenceIn_],
							   upper_[sequenceIn_],dualIn_);
						dualIn_ -= nonLinearCost_->changeUpInCost(sequenceIn_);
						printf(" to %g\n",dualIn_);
						nonLinearCost_->setOne(sequenceIn_,upper_[sequenceIn_]+2.0*currentPrimalTolerance());
						setStatus(sequenceIn_,IClpSimplex::atLowerBound);
					}
					break;
				case IClpSimplex::atLowerBound:
					if (dualIn_>0.0) {
						// move to other side
						printf("For %d L (%g, %g, %g) dj changed from %g",
							   sequenceIn_,lower_[sequenceIn_],solution_[sequenceIn_],
							   upper_[sequenceIn_],dualIn_);
						dualIn_ -= nonLinearCost_->changeDownInCost(sequenceIn_);
						printf(" to %g\n",dualIn_);
						nonLinearCost_->setOne(sequenceIn_,lower_[sequenceIn_]-2.0*currentPrimalTolerance());
						setStatus(sequenceIn_,IClpSimplex::atUpperBound);
					}
					break;
				default:
					break;
			}
		}
		lowerIn_=lower_[sequenceIn_];
		upperIn_=upper_[sequenceIn_];
		if (dualIn_>0.0)
			directionIn_ = -1;
		else
			directionIn_ = 1;
	} else {
		sequenceIn_ = -1;
	}
}
/* The primals are updated by the given array.
 Returns number of infeasibilities.
 After rowArray will have list of cost changes
 */
int
IClpSimplexPrimal::updatePrimalsInPrimal(CoinIndexedVector * rowArray,
											   double theta,
											   double & objectiveChange,
											   int valuesPass)
{
	// Cost on pivot row may change - may need to change dualIn
	double oldCost=0.0;
	if (pivotRow_>=0)
		oldCost = cost_[sequenceOut_];
	//rowArray->scanAndPack();
	double * work=rowArray->denseVector();
	int number=rowArray->getNumElements();
	int * which=rowArray->getIndices();

	int newNumber = 0;
	int pivotPosition = -1;
	nonLinearCost_->setChangeInCost(0.0);
	//printf("XX 4138 sol %g lower %g upper %g cost %g status %d\n",
	//   solution_[4138],lower_[4138],upper_[4138],cost_[4138],status_[4138]);
	// allow for case where bound+tolerance == bound
	//double tolerance = 0.999999*primalTolerance_;
	double relaxedTolerance = 1.001*primalTolerance_;
	int iIndex;
	if (!valuesPass) {
		for (iIndex=0;iIndex<number;iIndex++) {

			int iRow = which[iIndex];
			double alpha = work[iIndex];
			work[iIndex]=0.0;
			int iPivot=pivotVariable_[iRow];
			double change = theta*alpha;
			double value = solution_[iPivot] - change;
			solution_[iPivot]=value;
#ifndef NDEBUG
			// check if not active then okay
			if (!active(iRow)&&(specialOptions_&4)==0&&pivotRow_!=-1) {
				// But make sure one going out is feasible
				if (change>0.0) {
					// going down
					if (value<=lower_[iPivot]+primalTolerance_) {
						if (iPivot==sequenceOut_&&value>lower_[iPivot]-relaxedTolerance)
							value=lower_[iPivot];
						double difference = nonLinearCost_->setOne(iPivot,value);
						assert (!difference||fabs(change)>1.0e9);
					}
				} else {
					// going up
					if (value>=upper_[iPivot]-primalTolerance_) {
						if (iPivot==sequenceOut_&&value<upper_[iPivot]+relaxedTolerance)
							value=upper_[iPivot];
						double difference = nonLinearCost_->setOne(iPivot,value);
						assert (!difference||fabs(change)>1.0e9);
					}
				}
			}
#endif
			if (active(iRow)||theta_<0.0) {
				clearActive(iRow);
				// But make sure one going out is feasible
				if (change>0.0) {
					// going down
					if (value<=lower_[iPivot]+primalTolerance_) {
						if (iPivot==sequenceOut_&&value>=lower_[iPivot]-relaxedTolerance)
							value=lower_[iPivot];
						double difference = nonLinearCost_->setOne(iPivot,value);
						if (difference) {
							if (iRow==pivotRow_)
								pivotPosition=newNumber;
							work[newNumber] = difference;
							//change reduced cost on this
							dj_[iPivot] = -difference;
							which[newNumber++]=iRow;
						}
					}
				} else {
					// going up
					if (value>=upper_[iPivot]-primalTolerance_) {
						if (iPivot==sequenceOut_&&value<upper_[iPivot]+relaxedTolerance)
							value=upper_[iPivot];
						double difference = nonLinearCost_->setOne(iPivot,value);
						if (difference) {
							if (iRow==pivotRow_)
								pivotPosition=newNumber;
							work[newNumber] = difference;
							//change reduced cost on this
							dj_[iPivot] = -difference;
							which[newNumber++]=iRow;
						}
					}
				}
			}
		}
	} else {
		// values pass so look at all
		for (iIndex=0;iIndex<number;iIndex++) {

			int iRow = which[iIndex];
			double alpha = work[iIndex];
			work[iIndex]=0.0;
			int iPivot=pivotVariable_[iRow];
			double change = theta*alpha;
			double value = solution_[iPivot] - change;
			solution_[iPivot]=value;
			clearActive(iRow);
			// But make sure one going out is feasible
			if (change>0.0) {
				// going down
				if (value<=lower_[iPivot]+primalTolerance_) {
					if (iPivot==sequenceOut_&&value>lower_[iPivot]-relaxedTolerance)
						value=lower_[iPivot];
					double difference = nonLinearCost_->setOne(iPivot,value);
					if (difference) {
						if (iRow==pivotRow_)
							pivotPosition=newNumber;
						work[newNumber] = difference;
						//change reduced cost on this
						dj_[iPivot] = -difference;
						which[newNumber++]=iRow;
					}
				}
			} else {
				// going up
				if (value>=upper_[iPivot]-primalTolerance_) {
					if (iPivot==sequenceOut_&&value<upper_[iPivot]+relaxedTolerance)
						value=upper_[iPivot];
					double difference = nonLinearCost_->setOne(iPivot,value);
					if (difference) {
						if (iRow==pivotRow_)
							pivotPosition=newNumber;
						work[newNumber] = difference;
						//change reduced cost on this
						dj_[iPivot] = -difference;
						which[newNumber++]=iRow;
					}
				}
			}
		}
	}
	objectiveChange += nonLinearCost_->changeInCost();
	rowArray->setPacked();
#if 0
	rowArray->setNumElements(newNumber);
	rowArray->expand();
	if (pivotRow_>=0) {
		dualIn_ += (oldCost-cost_[sequenceOut_]);
		// update change vector to include pivot
		rowArray->add(pivotRow_,-dualIn_);
		// and convert to packed
		rowArray->scanAndPack();
	} else {
		// and convert to packed
		rowArray->scanAndPack();
	}
#else
	if (pivotRow_>=0) {
		double dualIn = dualIn_+(oldCost-cost_[sequenceOut_]);
		// update change vector to include pivot
		if (pivotPosition>=0) {
			work[pivotPosition] -= dualIn;
		} else {
			work[newNumber]=-dualIn;
			which[newNumber++]=pivotRow_;
		}
	}
	rowArray->setNumElements(newNumber);
#endif
	return 0;
}
// Perturbs problem
void
IClpSimplexPrimal::perturb(int type)
{
	if (perturbation_>100)
		return; //perturbed already
	if (perturbation_==100)
		perturbation_=50; // treat as normal
	int savePerturbation = perturbation_;
	int i;
	if (!numberIterations_)
		cleanStatus(); // make sure status okay
	// Make sure feasible bounds
	if (nonLinearCost_)
		nonLinearCost_->feasibleBounds();
	// look at element range
	double smallestNegative;
	double largestNegative;
	double smallestPositive;
	double largestPositive;
	matrix_->rangeOfElements(smallestNegative, largestNegative,
							 smallestPositive, largestPositive);
	smallestPositive = std::min(fabs(smallestNegative),smallestPositive);
	largestPositive = std::max(fabs(largestNegative),largestPositive);
	double elementRatio = largestPositive/smallestPositive;
	if (!numberIterations_&&perturbation_==50) {
		// See if we need to perturb
		double * sort = new double[numberRows_];
		for (i=0;i<numberRows_;i++) {
			double lo = fabs(rowLower_[i]);
			double up = fabs(rowUpper_[i]);
			double value=0.0;
			if (lo&&lo<1.0e20) {
				if (up&&up<1.0e20)
					value = 0.5*(lo+up);
				else
					value=lo;
			} else {
				if (up&&up<1.0e20)
					value = up;
			}
			sort[i]=value;
		}
		std::sort(sort,sort+numberRows_);
		int number=1;
		double last = sort[0];
		for (i=1;i<numberRows_;i++) {
			if (last!=sort[i])
				number++;
			last=sort[i];
		}
		delete [] sort;
		//printf("ratio number diff rhs %g, element ratio %g\n",((double)number)/((double) numberRows_),
		//								      elementRatio);
		if (number*3>numberRows_||elementRatio>1.0e12) {
			perturbation_=100;
			return; // good enough
		}
	}
	// primal perturbation
	double perturbation=1.0e-20;
	int numberNonZero=0;
	// maximum fraction of rhs/bounds to perturb
	double maximumFraction = 1.0e-5;
	if (perturbation_>=50) {
		perturbation = 1.0e-4;
		for (i=0;i<numberColumns_+numberRows_;i++) {
			if (upper_[i]>lower_[i]+primalTolerance_) {
				double lowerValue, upperValue;
				if (lower_[i]>-1.0e20)
					lowerValue = fabs(lower_[i]);
				else
					lowerValue=0.0;
				if (upper_[i]<1.0e20)
					upperValue = fabs(upper_[i]);
				else
					upperValue=0.0;
				double value = std::max(fabs(lowerValue),fabs(upperValue));
				value = std::min(value,upper_[i]-lower_[i]);
#if 1
				if (value) {
					perturbation += value;
					numberNonZero++;
				}
#else
				perturbation = std::max(perturbation,value);
#endif
			}
		}
		if (numberNonZero)
			perturbation /= static_cast<double> (numberNonZero);
		else
			perturbation = 1.0e-1;
		if (perturbation_>50&&perturbation_<60) {
			// reduce
			while (perturbation_>50) {
				perturbation_--;
				perturbation *= 0.25;
			}
		}
	} else if (perturbation_<100) {
		perturbation = pow(10.0,perturbation_);
		// user is in charge
		maximumFraction = 1.0;
	}
	double largestZero=0.0;
	double largest=0.0;
	double largestPerCent=0.0;
	bool printOut=(handler_->logLevel()==63);
	printOut=false; //off
	// Check if all slack
	int number=0;
	int iSequence;
	for (iSequence=0;iSequence<numberRows_;iSequence++) {
		if (getRowStatus(iSequence)==basic)
			number++;
	}
	if (rhsScale_>100.0) {
		// tone down perturbation
		maximumFraction *= 0.1;
	}
	if (number!=numberRows_)
		type=1;
	// modify bounds
	// Change so at least 1.0e-5 and no more than 0.1
	// For now just no more than 0.1
	// printf("Pert type %d perturbation %g, maxF %g\n",type,perturbation,maximumFraction);
	// seems much slower???#define SAVE_PERT
#ifdef SAVE_PERT
	if (2*numberColumns_>maximumPerturbationSize_) {
		delete [] perturbationArray_;
		maximumPerturbationSize_ = 2* numberColumns_;
		perturbationArray_ = new double [maximumPerturbationSize_];
		for (int iColumn=0;iColumn<maximumPerturbationSize_;iColumn++) {
			perturbationArray_[iColumn] = randomNumberGenerator_.randomDouble();
		}
	}
#endif
	if (type==1) {
		double tolerance = 100.0*primalTolerance_;
		//double multiplier = perturbation*maximumFraction;
		for (iSequence=0;iSequence<numberRows_+numberColumns_;iSequence++) {
			if (getStatus(iSequence)==basic) {
				double lowerValue = lower_[iSequence];
				double upperValue = upper_[iSequence];
				if (upperValue>lowerValue+tolerance) {
					double solutionValue = solution_[iSequence];
					double difference = upperValue-lowerValue;
					difference = std::min(difference,perturbation);
					difference = std::min(difference,fabs(solutionValue)+1.0);
					double value = maximumFraction*(difference+1.0);
					value = std::min(value,0.1);
#ifndef SAVE_PERT
					value *= randomNumberGenerator_.randomDouble();
#else
					value *= perturbationArray_[2*iSequence];
#endif
					if (solutionValue-lowerValue<=primalTolerance_) {
						lower_[iSequence] -= value;
					} else if (upperValue-solutionValue<=primalTolerance_) {
						upper_[iSequence] += value;
					} else {
#if 0
						if (iSequence>=numberColumns_) {
							// may not be at bound - but still perturb (unless free)
							if (upperValue>1.0e30&&lowerValue<-1.0e30)
								value=0.0;
							else
								value = - value; // as -1.0 in matrix
						} else {
							value = 0.0;
						}
#else
						value=0.0;
#endif
					}
					if (value) {
						if (printOut)
							printf("col %d lower from %g to %g, upper from %g to %g\n",
								   iSequence,lower_[iSequence],lowerValue,upper_[iSequence],upperValue);
						if (solutionValue) {
							largest = std::max(largest,value);
							if (value>(fabs(solutionValue)+1.0)*largestPerCent)
								largestPerCent=value/(fabs(solutionValue)+1.0);
						} else {
							largestZero = std::max(largestZero,value);
						}
					}
				}
			}
		}
	} else {
		double tolerance = 100.0*primalTolerance_;
		for (i=0;i<numberColumns_;i++) {
			double lowerValue=lower_[i], upperValue=upper_[i];
			if (upperValue>lowerValue+primalTolerance_) {
				double value = perturbation*maximumFraction;
				value = std::min(value,0.1);
#ifndef SAVE_PERT
				value *= randomNumberGenerator_.randomDouble();
#else
				value *= perturbationArray_[2*i+1];
#endif
				value *= randomNumberGenerator_.randomDouble();
				if (savePerturbation!=50) {
					if (fabs(value)<=primalTolerance_)
						value=0.0;
					if (lowerValue>-1.0e20&&lowerValue)
						lowerValue -= value * (std::max(1.0e-2,1.0e-5*fabs(lowerValue)));
					if (upperValue<1.0e20&&upperValue)
						upperValue += value * (std::max(1.0e-2,1.0e-5*fabs(upperValue)));
				} else if (value) {
					double valueL =value *(std::max(1.0e-2,1.0e-5*fabs(lowerValue)));
					// get in range
					if (valueL<=tolerance) {
						valueL *= 10.0;
						while (valueL<=tolerance)
							valueL *= 10.0;
					} else if (valueL>1.0) {
						valueL *= 0.1;
						while (valueL>1.0)
							valueL *= 0.1;
					}
					if (lowerValue>-1.0e20&&lowerValue)
						lowerValue -= valueL;
					double valueU =value *(std::max(1.0e-2,1.0e-5*fabs(upperValue)));
					// get in range
					if (valueU<=tolerance) {
						valueU *= 10.0;
						while (valueU<=tolerance)
							valueU *= 10.0;
					} else if (valueU>1.0) {
						valueU *= 0.1;
						while (valueU>1.0)
							valueU *= 0.1;
					}
					if (upperValue<1.0e20&&upperValue)
						upperValue += valueU;
				}
				if (lowerValue!=lower_[i]) {
					double difference = fabs(lowerValue-lower_[i]);
					largest = std::max(largest,difference);
					if (difference>fabs(lower_[i])*largestPerCent)
						largestPerCent=fabs(difference/lower_[i]);
				}
				if (upperValue!=upper_[i]) {
					double difference = fabs(upperValue-upper_[i]);
					largest = std::max(largest,difference);
					if (difference>fabs(upper_[i])*largestPerCent)
						largestPerCent=fabs(difference/upper_[i]);
				}
				if (printOut)
					printf("col %d lower from %g to %g, upper from %g to %g\n",
						   i,lower_[i],lowerValue,upper_[i],upperValue);
			}
			lower_[i]=lowerValue;
			upper_[i]=upperValue;
		}
		for (;i<numberColumns_+numberRows_;i++) {
			double lowerValue=lower_[i], upperValue=upper_[i];
			double value = perturbation*maximumFraction;
			value = std::min(value,0.1);
			value *= randomNumberGenerator_.randomDouble();
			if (upperValue>lowerValue+tolerance) {
				if (savePerturbation!=50) {
					if (fabs(value)<=primalTolerance_)
						value=0.0;
					if (lowerValue>-1.0e20&&lowerValue)
						lowerValue -= value * (std::max(1.0e-2,1.0e-5*fabs(lowerValue)));
					if (upperValue<1.0e20&&upperValue)
						upperValue += value * (std::max(1.0e-2,1.0e-5*fabs(upperValue)));
				} else if (value) {
					double valueL =value *(std::max(1.0e-2,1.0e-5*fabs(lowerValue)));
					// get in range
					if (valueL<=tolerance) {
						valueL *= 10.0;
						while (valueL<=tolerance)
							valueL *= 10.0;
					} else if (valueL>1.0) {
						valueL *= 0.1;
						while (valueL>1.0)
							valueL *= 0.1;
					}
					if (lowerValue>-1.0e20&&lowerValue)
						lowerValue -= valueL;
					double valueU =value *(std::max(1.0e-2,1.0e-5*fabs(upperValue)));
					// get in range
					if (valueU<=tolerance) {
						valueU *= 10.0;
						while (valueU<=tolerance)
							valueU *= 10.0;
					} else if (valueU>1.0) {
						valueU *= 0.1;
						while (valueU>1.0)
							valueU *= 0.1;
					}
					if (upperValue<1.0e20&&upperValue)
						upperValue += valueU;
				}
			} else if (upperValue>0.0) {
				upperValue -= value * (std::max(1.0e-2,1.0e-5*fabs(lowerValue)));
				lowerValue -= value * (std::max(1.0e-2,1.0e-5*fabs(lowerValue)));
			} else if (upperValue<0.0) {
				upperValue += value * (std::max(1.0e-2,1.0e-5*fabs(lowerValue)));
				lowerValue += value * (std::max(1.0e-2,1.0e-5*fabs(lowerValue)));
			} else {
			}
			if (lowerValue!=lower_[i]) {
				double difference = fabs(lowerValue-lower_[i]);
				largest = std::max(largest,difference);
				if (difference>fabs(lower_[i])*largestPerCent)
					largestPerCent=fabs(difference/lower_[i]);
			}
			if (upperValue!=upper_[i]) {
				double difference = fabs(upperValue-upper_[i]);
				largest = std::max(largest,difference);
				if (difference>fabs(upper_[i])*largestPerCent)
					largestPerCent=fabs(difference/upper_[i]);
			}
			if (printOut)
				printf("row %d lower from %g to %g, upper from %g to %g\n",
					   i-numberColumns_,lower_[i],lowerValue,upper_[i],upperValue);
			lower_[i]=lowerValue;
			upper_[i]=upperValue;
		}
	}
	// Clean up
	for (i=0;i<numberColumns_+numberRows_;i++) {
		switch(getStatus(i)) {

			case basic:
				break;
			case atUpperBound:
				solution_[i]=upper_[i];
				break;
			case isFixed:
			case atLowerBound:
	
Download .txt
gitextract_vql885vl/

├── .coin-or/
│   └── projDesc.xml
├── .github/
│   └── workflows/
│       ├── ci-cvxpy.yml
│       ├── cibuildwheel.yml
│       └── release.yml
├── .gitignore
├── AUTHORS
├── LICENSE
├── MANIFEST.in
├── README.rst
├── cylp/
│   ├── VERSION
│   ├── __init__.py
│   ├── cpp/
│   │   ├── .gitignore
│   │   ├── CbcCompareUser.cpp
│   │   ├── CbcCompareUser.hpp
│   │   ├── CyClpSimplex_api.h
│   │   ├── ICbc.cpp
│   │   ├── ICbc.hpp
│   │   ├── ICbcModel.cpp
│   │   ├── ICbcModel.hpp
│   │   ├── ICbcNode.cpp
│   │   ├── ICbcNode.hpp
│   │   ├── ICglCutGeneratorBase.cpp
│   │   ├── ICglCutGeneratorBase.h
│   │   ├── IClpDualRowPivotBase.cpp
│   │   ├── IClpDualRowPivotBase.h
│   │   ├── IClpPackedMatrix.cpp
│   │   ├── IClpPackedMatrix.hpp
│   │   ├── IClpPrimalColumnPivot.cpp
│   │   ├── IClpPrimalColumnPivot.h
│   │   ├── IClpPrimalColumnPivotBase.cpp
│   │   ├── IClpPrimalColumnPivotBase.h
│   │   ├── IClpSimplex.cpp
│   │   ├── IClpSimplex.hpp
│   │   ├── IClpSimplexPrimal.cpp
│   │   ├── IClpSimplexPrimal.hpp
│   │   ├── IClpSimplexPrimal_Wolfe.cpp
│   │   ├── IClpSimplexPrimal_Wolfe.hpp
│   │   ├── ICoinIndexedVector.cpp
│   │   ├── ICoinIndexedVector.hpp
│   │   ├── ICoinMP.cpp
│   │   ├── ICoinMP.hpp
│   │   ├── ICoinModel.hpp
│   │   ├── ICoinMpsIO.cpp
│   │   ├── ICoinMpsIO.hpp
│   │   ├── ICoinPackedMatrix.cpp
│   │   ├── ICoinPackedMatrix.hpp
│   │   ├── IOsiCuts.cpp
│   │   └── IOsiCuts.hpp
│   ├── cy/
│   │   ├── .gitignore
│   │   ├── CyCbcModel.pxd
│   │   ├── CyCbcModel.pyx
│   │   ├── CyCbcNode.pxd
│   │   ├── CyCbcNode.pyx
│   │   ├── CyCgl.pxd
│   │   ├── CyCgl.pyx
│   │   ├── CyCglCutGeneratorBase.pxd
│   │   ├── CyCglCutGeneratorBase.pyx
│   │   ├── CyCglTreeInfo.pxd
│   │   ├── CyCglTreeInfo.pyx
│   │   ├── CyClpDualRowPivotBase.pxd
│   │   ├── CyClpDualRowPivotBase.pyx
│   │   ├── CyClpPrimalColumnPivotBase.pxd
│   │   ├── CyClpPrimalColumnPivotBase.pyx
│   │   ├── CyClpPrimalColumnSteepest.pyx
│   │   ├── CyClpSimplex.pxd
│   │   ├── CyClpSimplex.pyx
│   │   ├── CyClpSimplex_api.h
│   │   ├── CyCoinIndexedVector.pxd
│   │   ├── CyCoinIndexedVector.pyx
│   │   ├── CyCoinModel.pxd
│   │   ├── CyCoinModel.pyx
│   │   ├── CyCoinMpsIO.pxd
│   │   ├── CyCoinMpsIO.pyx
│   │   ├── CyCoinPackedMatrix.pxd
│   │   ├── CyCoinPackedMatrix.pyx
│   │   ├── CyCutGeneratorPythonBase.pxd
│   │   ├── CyCutGeneratorPythonBase.pyx
│   │   ├── CyDantzigPivot.pxd
│   │   ├── CyDantzigPivot.pyx
│   │   ├── CyDualPivotPythonBase.pxd
│   │   ├── CyDualPivotPythonBase.pyx
│   │   ├── CyOsiCuts.pxd
│   │   ├── CyOsiCuts.pyx
│   │   ├── CyOsiSolverInterface.pxd
│   │   ├── CyOsiSolverInterface.pyx
│   │   ├── CyPEPivot.pxd
│   │   ├── CyPEPivot.pyx
│   │   ├── CyPivotPythonBase.pxd
│   │   ├── CyPivotPythonBase.pyx
│   │   ├── CySolve.py
│   │   ├── CyTest.pyx
│   │   ├── CyWolfePivot.pxd
│   │   ├── CyWolfePivot.pyx
│   │   ├── __init__.py
│   │   └── createCythonInterface.py
│   ├── doc/
│   │   ├── .gitignore
│   │   ├── Makefile
│   │   ├── mathjax.py
│   │   └── source/
│   │       ├── conf.py
│   │       ├── index.rst
│   │       └── modules/
│   │           ├── CyCbcModel.rst
│   │           ├── CyClpSimplex.rst
│   │           ├── CyCoinIndexedVector.rst
│   │           ├── CyCoinModel.rst
│   │           ├── CyCoinMpsIO.rst
│   │           ├── CyCoinPackedMatrix.rst
│   │           ├── CyPivotPythonBase.rst
│   │           ├── DantzigPivot.rst
│   │           ├── DualDantzigPivot.rst
│   │           ├── LIFOPivot.rst
│   │           ├── MostFrequentPivot.rst
│   │           ├── PivotPythonBase.rst
│   │           ├── PositiveEdgePivot.rst
│   │           ├── cy.rst
│   │           ├── modeling.rst
│   │           ├── pivots.rst
│   │           ├── py.rst
│   │           └── sparseUtil.rst
│   ├── input/
│   │   ├── aug3dcqp.qps
│   │   ├── cvxqp1_s.qps
│   │   ├── cvxqp2_s.qps
│   │   ├── fileDownloader.py
│   │   ├── h.qps
│   │   ├── hs268.qps
│   │   ├── hs268_2.qps
│   │   ├── hs268_p.qps
│   │   ├── hs35.qps
│   │   ├── hs35_2.qps
│   │   ├── netlib/
│   │   │   ├── 25fv47.mps
│   │   │   ├── 80bau3b.mps
│   │   │   ├── adlittle.mps
│   │   │   ├── afiro.mps
│   │   │   ├── agg.mps
│   │   │   ├── agg2.mps
│   │   │   ├── agg3.mps
│   │   │   ├── ascii
│   │   │   ├── bandm.mps
│   │   │   ├── beaconfd.mps
│   │   │   ├── blend.mps
│   │   │   ├── bnl1.mps
│   │   │   ├── bnl2.mps
│   │   │   ├── boeing1.mps
│   │   │   ├── boeing2.mps
│   │   │   ├── bore3d.mps
│   │   │   ├── brandy.mps
│   │   │   ├── capri.mps
│   │   │   ├── changes
│   │   │   ├── cycle.mps
│   │   │   ├── czprob.mps
│   │   │   ├── d2q06c.mps
│   │   │   ├── d6cube.mps
│   │   │   ├── degen2.mps
│   │   │   ├── degen3.mps
│   │   │   ├── dfl001.mps
│   │   │   ├── e226.mps
│   │   │   ├── etamacro.mps
│   │   │   ├── fffff800.mps
│   │   │   ├── fileDownloader.py
│   │   │   ├── finnis.mps
│   │   │   ├── fit1d.mps
│   │   │   ├── fit1p.mps
│   │   │   ├── fit2d.mps
│   │   │   ├── fit2p.mps
│   │   │   ├── forplan.mps
│   │   │   ├── ganges.mps
│   │   │   ├── gfrd-pnc.mps
│   │   │   ├── greenbea.mps
│   │   │   ├── greenbeb.mps
│   │   │   ├── grow15.mps
│   │   │   ├── grow22.mps
│   │   │   ├── grow7.mps
│   │   │   ├── israel.mps
│   │   │   ├── kb2.mps
│   │   │   ├── lotfi.mps
│   │   │   ├── maros
│   │   │   ├── maros-r7.mps
│   │   │   ├── maros.mps
│   │   │   ├── minos
│   │   │   ├── modszk1.mps
│   │   │   ├── nesm.mps
│   │   │   ├── perold.mps
│   │   │   ├── pilot.ja.mps
│   │   │   ├── pilot.mps
│   │   │   ├── pilot.we.mps
│   │   │   ├── pilot4.mps
│   │   │   ├── pilot87.mps
│   │   │   ├── pilotnov.mps
│   │   │   ├── readme
│   │   │   ├── recipe.mps
│   │   │   ├── sc105.mps
│   │   │   ├── sc205.mps
│   │   │   ├── sc50a.mps
│   │   │   ├── sc50b.mps
│   │   │   ├── scagr25.mps
│   │   │   ├── scagr7.mps
│   │   │   ├── scfxm1.mps
│   │   │   ├── scfxm2.mps
│   │   │   ├── scfxm3.mps
│   │   │   ├── scorpion.mps
│   │   │   ├── scrs8.mps
│   │   │   ├── scsd1.mps
│   │   │   ├── scsd6.mps
│   │   │   ├── scsd8.mps
│   │   │   ├── sctap1.mps
│   │   │   ├── sctap2.mps
│   │   │   ├── sctap3.mps
│   │   │   ├── seba.mps
│   │   │   ├── share1b.mps
│   │   │   ├── share2b.mps
│   │   │   ├── shell.mps
│   │   │   ├── ship04l.mps
│   │   │   ├── ship04s.mps
│   │   │   ├── ship08l.mps
│   │   │   ├── ship08s.mps
│   │   │   ├── ship12l.mps
│   │   │   ├── ship12s.mps
│   │   │   ├── sierra.mps
│   │   │   ├── stair.mps
│   │   │   ├── standata.mps
│   │   │   ├── standgub.mps
│   │   │   ├── standmps.mps
│   │   │   ├── stocfor1.mps
│   │   │   ├── stocfor2.mps
│   │   │   ├── stocfor3.old
│   │   │   ├── truss
│   │   │   ├── tuff.mps
│   │   │   ├── vtp.base.mps
│   │   │   ├── wood1p.mps
│   │   │   └── woodw.mps
│   │   ├── nsct1.mps
│   │   ├── p0033.mps
│   │   └── pp.qps
│   ├── py/
│   │   ├── Constants.py
│   │   ├── PySolve.py
│   │   ├── QP/
│   │   │   ├── GQP.py
│   │   │   ├── QP.py
│   │   │   ├── QPGen.py
│   │   │   ├── QPSReader.py
│   │   │   └── __init__.py
│   │   ├── __init__.py
│   │   ├── mip/
│   │   │   ├── CyLPCutGenerator.py
│   │   │   ├── GomoryCutGenerator.py
│   │   │   ├── NodeCompareBase.py
│   │   │   ├── SimpleNodeCompare.py
│   │   │   └── __init__.py
│   │   ├── modeling/
│   │   │   ├── CyLPModel.py
│   │   │   ├── __init__.py
│   │   │   └── test_modeling.py
│   │   ├── pivots/
│   │   │   ├── DantzigPivot.py
│   │   │   ├── DualDantzigPivot.py
│   │   │   ├── DualPivotPythonBase.py
│   │   │   ├── LIFOPivot.py
│   │   │   ├── MostFrequentPivot.py
│   │   │   ├── PivotPythonBase.py
│   │   │   ├── PositiveEdgePivot.py
│   │   │   ├── PositiveEdgeWolfePivot.py
│   │   │   ├── WolfePivot.py
│   │   │   ├── WolfePivotPE.py
│   │   │   └── __init__.py
│   │   ├── test_PySolve.py
│   │   └── utils/
│   │       ├── __init__.py
│   │       ├── readSetcovering.py
│   │       ├── sparseUtil.py
│   │       └── util.py
│   └── tests/
│       ├── __init__.py
│       ├── test_CyClpSimplex.py
│       ├── test_CyClpSimplex_CyLPModel.py
│       ├── test_CyCoinIndexedVector.py
│       ├── test_CyCoinModel.py
│       ├── test_CyCoinMpsIO.py
│       ├── test_CySolve.py
│       ├── test_IO.py
│       ├── test_IndexFactory.py
│       ├── test_MIP.py
│       ├── test_QP.py
│       ├── test_argWeightedMax.py
│       ├── test_sparseUtil.py
│       └── test_warmStart.py
├── fixBinaries.py
├── pyproject.toml
└── setup.py
Download .txt
SYMBOL INDEX (485 symbols across 71 files)

FILE: cylp/cpp/CbcCompareUser.cpp
  function CbcCompareBase (line 69) | CbcCompareBase *
  function CbcCompareUser (line 76) | CbcCompareUser &

FILE: cylp/cpp/CbcCompareUser.hpp
  class CbcCompareUser (line 24) | class CbcCompareUser  : public CbcCompareBase {
    method getWeight (line 63) | inline double getWeight() const
    method setWeight (line 65) | inline void setWeight(double weight)

FILE: cylp/cpp/CyClpSimplex_api.h
  function PyObject (line 12) | static PyObject *__Pyx_ImportModule(const char *name) {
  function __Pyx_ImportFunction (line 30) | static int __Pyx_ImportFunction(PyObject *module, const char *funcname, ...
  function import_CyClpSimplex (line 66) | static int import_CyClpSimplex(void) {

FILE: cylp/cpp/ICbc.cpp
  function ICbcModel (line 3) | ICbcModel* CbcSolveMIP(IClpSimplex* clpModel, PyObject* obj,
  function ICbcModel (line 18) | ICbcModel* CbcSolveMIP(IClpSimplex* clpModel){

FILE: cylp/cpp/ICbcModel.cpp
  function PyObject (line 6) | PyObject* ICbcModel::getPrimalVariableSolution(){

FILE: cylp/cpp/ICbcModel.hpp
  class ICbcModel (line 20) | class ICbcModel
  class ICbcModel (line 30) | class ICbcModel : public CbcModel{

FILE: cylp/cpp/ICbcNode.hpp
  class ICbcNode (line 17) | class ICbcNode : public CbcNode{

FILE: cylp/cpp/ICglCutGeneratorBase.cpp
  function CglCutGenerator (line 16) | CglCutGenerator * CppCglCutGeneratorBase::clone() const {

FILE: cylp/cpp/ICglCutGeneratorBase.h
  type CglCutGenerator (line 12) | typedef CglCutGenerator* (*runCglClone_t)(void *instance);
  function class (line 18) | class CppCglCutGeneratorBase : public CglCutGenerator

FILE: cylp/cpp/IClpDualRowPivotBase.cpp
  function ClpDualRowPivot (line 16) | ClpDualRowPivot * CppClpDualRowPivotBase::clone(bool copyData) const {
  function IClpSimplex (line 76) | IClpSimplex* CppClpDualRowPivotBase::model()

FILE: cylp/cpp/IClpDualRowPivotBase.h
  type ClpDualRowPivot (line 13) | typedef ClpDualRowPivot* (*runDualPivotClone_t)(void *instance, bool cop...
  function class (line 28) | class CppClpDualRowPivotBase : public ClpDualRowPivot

FILE: cylp/cpp/IClpPackedMatrix.hpp
  class IClpPackedMatrix (line 14) | class IClpPackedMatrix : public ClpPackedMatrix{

FILE: cylp/cpp/IClpPrimalColumnPivot.cpp
  function CppClpPrimalColumnPivotBase (line 29) | CppClpPrimalColumnPivotBase* CppClpPrimalColumnPivotBase::clone(bool cop...

FILE: cylp/cpp/IClpPrimalColumnPivot.h
  function class (line 9) | class CppClpPrimalColumnPivotBase : public ClpPrimalColumnPivot

FILE: cylp/cpp/IClpPrimalColumnPivotBase.cpp
  function ClpPrimalColumnPivot (line 18) | ClpPrimalColumnPivot * CppClpPrimalColumnPivotBase::clone(bool copyData)...
  function IClpSimplex (line 59) | IClpSimplex* CppClpPrimalColumnPivotBase::model()

FILE: cylp/cpp/IClpPrimalColumnPivotBase.h
  type ClpPrimalColumnPivot (line 14) | typedef ClpPrimalColumnPivot* (*runClone_t)(void *instance, bool copyData);
  function class (line 20) | class CppClpPrimalColumnPivotBase : public ClpPrimalColumnPivot

FILE: cylp/cpp/IClpSimplex.cpp
  function PyObject (line 347) | PyObject* IClpSimplex::getStatusArray(){
  function PyObject (line 356) | PyObject* IClpSimplex::getReducedCosts(){
  function PyObject (line 372) | PyObject* IClpSimplex::getComplementarityList(){
  function PyObject (line 380) | PyObject* IClpSimplex::getPivotVariable(){
  function PyObject (line 389) | PyObject* IClpSimplex::getPrimalRowSolution(){
  function PyObject (line 397) | PyObject* IClpSimplex::getPrimalColumnSolution(){
  function PyObject (line 405) | PyObject* IClpSimplex::getPrimalColumnSolutionAll(){
  function PyObject (line 411) | PyObject* IClpSimplex::getSolutionRegion(){
  function PyObject (line 417) | PyObject* IClpSimplex::getCostRegion(){
  function PyObject (line 423) | PyObject* IClpSimplex::getDualRowSolution(){
  function PyObject (line 431) | PyObject* IClpSimplex::getDualColumnSolution(){
  function PyObject (line 439) | PyObject* IClpSimplex::getObjective(){
  function PyObject (line 446) | PyObject* IClpSimplex::getRowLower(){
  function PyObject (line 453) | PyObject* IClpSimplex::getRowUpper(){
  function PyObject (line 460) | PyObject* IClpSimplex::getUpper(){
  function PyObject (line 467) | PyObject* IClpSimplex::getLower(){
  function PyObject (line 474) | PyObject* IClpSimplex::getColLower(){
  function PyObject (line 481) | PyObject* IClpSimplex::getColUpper(){
  function PyObject (line 488) | PyObject* IClpSimplex::getColumnScale(){
  function PyObject (line 495) | PyObject* IClpSimplex::getRowScale(){
  function PyObject (line 504) | PyObject* IClpSimplex::getIntegerInformation(){
  function ICbcModel (line 730) | ICbcModel* IClpSimplex::getICbcModel(){
  function IClpSimplex (line 1008) | IClpSimplex* IClpSimplex::preSolve(IClpSimplex* si,
  function cdot (line 1375) | double cdot(CoinIndexedVector* pv1, CoinIndexedVector* pv2){
  function PyObject (line 1386) | PyObject* IClpSimplex::filterVars(PyObject* inds){

FILE: cylp/cpp/IClpSimplex.hpp
  class IClpSimplex (line 27) | class IClpSimplex : public ClpSimplex{
    method updateColumnFT (line 98) | int updateColumnFT(CoinIndexedVector * spare,
    method updateColumnTranspose (line 104) | int updateColumnTranspose (CoinIndexedVector * regionSparse,
    method setPrimalColumnPivotAlgorithm (line 114) | void setPrimalColumnPivotAlgorithm(ClpPrimalColumnPivot *choice){ClpSi...
    method setDualRowPivotAlgorithm (line 115) | void setDualRowPivotAlgorithm(ClpDualRowPivot *choice){ClpSimplex::set...
    method loadQuadraticObjective (line 117) | void loadQuadraticObjective(const CoinPackedMatrix* matrix){ClpModel::...
    method ICoinPackedMatrix (line 118) | ICoinPackedMatrix* getMatrix(){return static_cast<ICoinPackedMatrix*>(...
    method loadProblem (line 120) | int loadProblem (CoinModel * modelObject,bool tryPlusMinusOne=false){r...
    method loadProblem (line 122) | void loadProblem (const CoinPackedMatrix* matrix,
    method setComplement (line 178) | void setComplement(int var1, int var2){QP_ComplementarityList[var1] = ...
    method getCoinInfinity (line 181) | inline double getCoinInfinity(){return COIN_DBL_MAX;}
    method setColumnUpperArray (line 183) | inline void setColumnUpperArray(double *cu){columnUpper_ = cu;}
    method setColumnLowerArray (line 184) | inline void setColumnLowerArray(double *cl){columnLower_ = cl;}
    method setRowUpperArray (line 185) | inline void setRowUpperArray(double *ru){rowUpper_ = ru;}
    method setRowLowerArray (line 186) | inline void setRowLowerArray(double *rl){rowLower_ = rl;}
    method setColumnUpperSubset (line 188) | inline void setColumnUpperSubset(int n, int *indicesOfIndices, int *in...
    method setColumnLowerSubset (line 192) | inline void setColumnLowerSubset(int n, int *indicesOfIndices, int *in...
    method setColumnUpperFirstElements (line 197) | inline void setColumnUpperFirstElements(int n, double* values){
    method setColumnLowerFirstElements (line 201) | inline void setColumnLowerFirstElements(int n, double* values){
    method setObjectiveArray (line 206) | inline void setObjectiveArray(double *o, int numberColumns)
    method partialPrice (line 218) | int partialPrice(int start, int end, int* numberWanted)

FILE: cylp/cpp/IClpSimplexPrimal.hpp
  class IClpSimplexPrimal (line 23) | class IClpSimplexPrimal : public IClpSimplex{

FILE: cylp/cpp/IClpSimplexPrimal_Wolfe.hpp
  class IClpSimplexPrimal_Wolfe (line 24) | class IClpSimplexPrimal_Wolfe : public IClpSimplex{

FILE: cylp/cpp/ICoinIndexedVector.cpp
  function PyObject (line 11) | PyObject* ICoinIndexedVector::getIndicesNPArray(){
  function PyObject (line 20) | PyObject* ICoinIndexedVector::getDenseVectorNPArray(){

FILE: cylp/cpp/ICoinIndexedVector.hpp
  class ICoinIndexedVector (line 12) | class ICoinIndexedVector : public CoinIndexedVector{
    method Print (line 20) | void Print(){print();}

FILE: cylp/cpp/ICoinMP.cpp
  function IterCallback (line 6) | int SOLVCALL IterCallback(int    IterCount,
  function MipNodeCallback (line 16) | int SOLVCALL MipNodeCallback(int    IterCount,
  function SOLVAPI (line 27) | SOLVAPI HPROB SOLVCALL CoinCreateProblem(const char* ProblemName, IClpSi...
  function SolveMIP (line 115) | void SolveMIP(char* problemName, char* columnType, IClpSimplex* clpmodel)

FILE: cylp/cpp/ICoinMP.hpp
  class CBIterHandler (line 28) | class  CBIterHandler
  class CBMessageHandler (line 29) | class CBMessageHandler
  class CBNodeHandler (line 30) | class CBNodeHandler

FILE: cylp/cpp/ICoinModel.hpp
  class ICoinModel (line 10) | class ICoinModel: public CoinModel{
    method addRow (line 12) | void addRow(int numberInRow, const int * columns,
    method addColumn (line 17) | void addColumn(int numberInColumn, const int * rows,

FILE: cylp/cpp/ICoinMpsIO.cpp
  function PyObject (line 88) | PyObject* ICoinMpsIO::np_getColLower(){
  function PyObject (line 96) | PyObject* ICoinMpsIO::np_getColUpper(){
  function PyObject (line 103) | PyObject* ICoinMpsIO::np_getRowSense(){
  function PyObject (line 111) | PyObject* ICoinMpsIO::np_getRightHandSide(){
  function PyObject (line 118) | PyObject* ICoinMpsIO::np_getRowRange(){
  function PyObject (line 125) | PyObject* ICoinMpsIO::np_getRowLower(){
  function PyObject (line 132) | PyObject* ICoinMpsIO::np_getRowUpper(){
  function PyObject (line 139) | PyObject* ICoinMpsIO::np_getObjCoefficients(){
  function PyObject (line 146) | PyObject* ICoinMpsIO::np_integerColumns(){
  function PyObject (line 154) | PyObject* ICoinMpsIO::getQPColumnStarts(){
  function PyObject (line 161) | PyObject* ICoinMpsIO::getQPColumns(){
  function PyObject (line 168) | PyObject* ICoinMpsIO::getQPElements(){
  function ICoinPackedMatrix (line 209) | ICoinPackedMatrix * ICoinMpsIO::IgetMatrixByRow() const
  function ICoinPackedMatrix (line 221) | ICoinPackedMatrix * ICoinMpsIO::IgetMatrixByCol() const

FILE: cylp/cpp/ICoinMpsIO.hpp
  class ICoinMpsIO (line 13) | class ICoinMpsIO : public CoinMpsIO{

FILE: cylp/cpp/ICoinPackedMatrix.cpp
  function PyObject (line 3) | PyObject* ICoinPackedMatrix::np_getIndices(){
  function PyObject (line 11) | PyObject* ICoinPackedMatrix::np_getElements(){
  function PyObject (line 19) | PyObject* ICoinPackedMatrix::np_getMajorIndices(){
  function PyObject (line 28) | PyObject* ICoinPackedMatrix::np_getVectorStarts(){

FILE: cylp/cpp/ICoinPackedMatrix.hpp
  class ICoinPackedMatrix (line 12) | class ICoinPackedMatrix : public CoinPackedMatrix{
    method CoinBigIndex (line 21) | inline CoinBigIndex * IgetVectorStarts() const { return start_; }

FILE: cylp/cpp/IOsiCuts.hpp
  class CppOsiCuts (line 9) | class CppOsiCuts : public OsiCuts

FILE: cylp/cy/CyClpSimplex_api.h
  function PyObject (line 12) | static PyObject *__Pyx_ImportModule(const char *name) {
  function __Pyx_ImportFunction (line 30) | static int __Pyx_ImportFunction(PyObject *module, const char *funcname, ...
  function import_CyClpSimplex (line 66) | static int import_CyClpSimplex(void) {

FILE: cylp/doc/mathjax.py
  function html_visit_math (line 22) | def html_visit_math(self, node):
  function html_visit_displaymath (line 29) | def html_visit_displaymath(self, node):
  function builder_inited (line 56) | def builder_inited(app):
  function setup (line 62) | def setup(app):

FILE: cylp/py/PySolve.py
  function solve (line 13) | def solve(filename, method):

FILE: cylp/py/QP/GQP.py
  class GQP (line 8) | class GQP(QP.QP):
    method __init__ (line 13) | def __init__(self, L, a, CT, b, ne=0):
    method sSome (line 55) | def sSome(self, x, subsetOfCons):
    method getq (line 59) | def getq(self):
    method getMostViolatedConst (line 67) | def getMostViolatedConst(self, x):
    method getJ1 (line 83) | def getJ1(self):
    method getJ2 (line 91) | def getJ2(self):
    method getd1 (line 99) | def getd1(self, i):
    method getd2 (line 104) | def getd2(self, i):
    method getDualDirect_Step (line 109) | def getDualDirect_Step(self, r):
    method checkInvars (line 119) | def checkInvars(self):
    method addConstraint (line 143) | def addConstraint(self, i, d1=None, d2=None):
    method removeConstraint (line 167) | def removeConstraint(self, l, uPlus):
    method minStep (line 215) | def minStep(self, t1, t2):
    method getMinRatio (line 227) | def getMinRatio(self, uPlus, r, sign=1):
    method dual (line 240) | def dual(self, verbose):
    method primal (line 325) | def primal(self, x, A, verbose):

FILE: cylp/py/QP/QP.py
  function getSolution (line 18) | def getSolution(s, varGroupname):
  function checkComp (line 31) | def checkComp(x, y):
  class QP (line 38) | class QP:
    method __init__ (line 40) | def __init__(self):
    method ComputeObjectiveValue (line 44) | def ComputeObjectiveValue(self, x):
    method init (line 48) | def init(self, G, c, A, b, C, c_low, c_up, x_low, x_up):
    method sAll (line 63) | def sAll(self, x):
    method s (line 69) | def s(self, x, i):
    method getUnconstrainedSol (line 81) | def getUnconstrainedSol(self):
    method gradient (line 89) | def gradient(self, x):
    method fromQps (line 97) | def fromQps(self, filename):
    method convertToEqualityOnly (line 107) | def convertToEqualityOnly(self, varsToo=True):
    method WolfeEquality (line 326) | def WolfeEquality(self, method='w'):
    method writeReport (line 523) | def writeReport(self, filename, s, timeToMake, timeToSolve, method, p):
    method Wolfe_2 (line 561) | def Wolfe_2(self):
    method Wolfe (line 891) | def Wolfe(self, method='w'):
  function getStat (line 1640) | def getStat():
  function QPTest (line 1650) | def QPTest():

FILE: cylp/py/QP/QPGen.py
  function getA (line 10) | def getA(nRows, nCols, nnzPerCol):
  function getG (line 31) | def getG(nCols):
  function getCoinInfinity (line 42) | def getCoinInfinity():
  function generateRandomPositiveDefiniteMatrix (line 45) | def generateRandomPositiveDefiniteMatrix(n, cond):
  function getQP (line 66) | def getQP(m, n):
  class QPGen (line 95) | class QPGen:
    method __init__ (line 96) | def __init__(self, n, m, HesCond, nnzPerCol, costRange, signs):
    method generateQP (line 105) | def generateQP(self):
    method writeToFile (line 150) | def writeToFile(self):

FILE: cylp/py/QP/QPSReader.py
  function readQPS (line 7) | def readQPS(inputFilename):

FILE: cylp/py/mip/CyLPCutGenerator.py
  class cylpCutGenerator (line 1) | class cylpCutGenerator:
    method generateCuts (line 5) | def generateCuts(self, x, y, z):

FILE: cylp/py/mip/GomoryCutGenerator.py
  function isInt (line 10) | def isInt(x):
  function gomoryCut (line 19) | def gomoryCut(lp, rowInd):
  function getFraction (line 30) | def getFraction(x):
  class GomoryCutGenerator (line 34) | class GomoryCutGenerator:
    method __init__ (line 35) | def __init__(self, cyLPModel):
    method generateCuts (line 38) | def generateCuts(self, si, cglTreeInfo):

FILE: cylp/py/mip/NodeCompareBase.py
  class NodeCompareBase (line 1) | class NodeCompareBase:
    method compare (line 5) | def compare(self, x, y):
    method newSolution (line 19) | def newSolution(self, model,
    method every1000Nodes (line 32) | def every1000Nodes(self, model, numberNodes):

FILE: cylp/py/mip/SimpleNodeCompare.py
  class SimpleNodeCompare (line 3) | class SimpleNodeCompare(NodeCompareBase):
    method __init__ (line 5) | def __init__(self):
    method compare (line 8) | def compare(self, x, y):
    method newSolution (line 20) | def newSolution(self, model,
    method every1000Nodes (line 28) | def every1000Nodes(self, model, numberNodes):

FILE: cylp/py/modeling/CyLPModel.py
  function isNumber (line 132) | def isNumber(n):
  function I (line 141) | def I(n):
  function identitySub (line 150) | def identitySub(var):
  class CyLPExpr (line 164) | class CyLPExpr:
    method __init__ (line 169) | def __init__(self, opr='', left='', right=''):
    method __hash__ (line 176) | def __hash__(self):
    method __repr__ (line 179) | def __repr__(self):
    method __le__ (line 183) | def __le__(self, other):
    method __ge__ (line 188) | def __ge__(self, other):
    method __eq__ (line 193) | def __eq__(self, other):
    method __rmul__ (line 205) | def __rmul__(self, other):
    method __mul__ (line 213) | def __mul__(self, other):
    method __rmatmul__ (line 221) | def __rmatmul__(self, other):
    method __matmul__ (line 227) | def __matmul__(self, other):
    method __rsub__ (line 233) | def __rsub__(self, other):
    method __sub__ (line 239) | def __sub__(self, other):
    method __radd__ (line 245) | def __radd__(self, other):
    method __add__ (line 251) | def __add__(self, other):
    method __neg__ (line 257) | def __neg__(self):
    method getPostfix (line 263) | def getPostfix(self):
    method evaluate (line 275) | def evaluate(self, name=''):
  class CyLPConstraint (line 321) | class CyLPConstraint:
    method __init__ (line 323) | def __init__(self, name=''):
    method __repr__ (line 337) | def __repr__(self):
    method mul (line 352) | def mul(self, expr, coef):
    method perform (line 366) | def perform(self, opr, left=None, right=None):
  class CyLPVar (line 557) | class CyLPVar(CyLPExpr):
    method __init__ (line 568) | def __init__(self, name, dim, isInt=False, fromInd=None, toInd=None):
    method __repr__ (line 593) | def __repr__(self):
    method setDims (line 601) | def setDims(self, ds):
    method __getitem__ (line 604) | def __getitem__(self, key):
    method sum (line 648) | def sum(self):
  class CyLPArray (line 655) | class CyLPArray(np.ndarray):
    method __new__ (line 669) | def __new__(cls, input_array, info=None):
    method __le__ (line 678) | def __le__(self, other):
    method __ge__ (line 683) | def __ge__(self, other):
    method __mul__ (line 688) | def __mul__(self, other):
    method __rmul__ (line 693) | def __rmul__(self, other):
    method __add__ (line 698) | def __add__(self, other):
    method __radd__ (line 703) | def __radd__(self, other):
    method __rsub__ (line 708) | def __rsub__(self, other):
    method __sub__ (line 713) | def __sub__(self, other):
  class IndexFactory (line 719) | class IndexFactory:
    method __init__ (line 744) | def __init__(self):
    method addVar (line 750) | def addVar(self, varName, numberOfVars):
    method removeVar (line 766) | def removeVar(self, name):
    method hasVar (line 778) | def hasVar(self, varName):
    method hasConst (line 781) | def hasConst(self, constName):
    method getLastVarIndex (line 784) | def getLastVarIndex(self):
    method addConst (line 787) | def addConst(self, constName, numberOfConsts):
    method removeConst (line 802) | def removeConst(self, name):
    method getLastConstIndex (line 816) | def getLastConstIndex(self):
    method __repr__ (line 819) | def __repr__(self):
    method reverseVarSearch (line 832) | def reverseVarSearch(self, ind):
  class CyLPModel (line 846) | class CyLPModel(object):
    method __init__ (line 855) | def __init__(self):
    method addVariable (line 865) | def addVariable(self, name, dim, isInt=False):
    method removeVariable (line 910) | def removeVariable(self, name):
    method getVarByName (line 964) | def getVarByName(self, varName):
    method makeIndexFactory (line 973) | def makeIndexFactory(self):
    method objective (line 990) | def objective(self):
    method objective (line 994) | def objective(self, obj):
    method evaluateAt (line 1005) | def evaluateAt(self, x0):
    method __iadd__ (line 1008) | def __iadd__(self, cons):
    method addConstraint (line 1016) | def addConstraint(self, cons, consName='', addMpsNames=True):
    method removeConstraint (line 1044) | def removeConstraint(self, name):
    method generateVarObjCoef (line 1062) | def generateVarObjCoef(self, varName):
    method generateVarMatrix (line 1073) | def generateVarMatrix(self, varName):
    method makeMatrices (line 1090) | def makeMatrices(self):
  class CyLPSolution (line 1137) | class CyLPSolution:
    method __init__ (line 1139) | def __init__(self):
    method add (line 1142) | def add(self, key, val):
    method getVal (line 1148) | def getVal(self, key):
    method __getitem__ (line 1154) | def __getitem__(self, key):
    method __setitem__ (line 1161) | def __setitem__(self, key, val):
    method __repr__ (line 1166) | def __repr__(self):
  function getCoinInfinity (line 1169) | def getCoinInfinity():

FILE: cylp/py/modeling/test_modeling.py
  class TestModeling (line 12) | class TestModeling(unittest.TestCase):
    method setUp (line 14) | def setUp(self):
    method test_Obj1 (line 27) | def test_Obj1(self):
    method test_variableBoundSubset (line 45) | def test_variableBoundSubset(self):
    method test_bound1 (line 71) | def test_bound1(self):
    method test_bound2 (line 79) | def test_bound2(self):
    method test_bound3 (line 87) | def test_bound3(self):
    method test_bound4 (line 103) | def test_bound4(self):
    method test_constraint_single1 (line 115) | def test_constraint_single1(self):
    method test_constraint_single2 (line 125) | def test_constraint_single2(self):
    method test_constraint_single3 (line 140) | def test_constraint_single3(self):
    method test_constraint_1 (line 152) | def test_constraint_1(self):
    method test_removeConst (line 167) | def test_removeConst(self):
    method test_removeVar (line 190) | def test_removeVar(self):
    method test_removeVar2 (line 219) | def test_removeVar2(self):

FILE: cylp/py/pivots/DantzigPivot.py
  class DantzigPivot (line 15) | class DantzigPivot(PivotPythonBase):
    method __init__ (line 38) | def __init__(self, clpModel):
    method pivotColumn (line 42) | def pivotColumn(self, updates, spareRow1, spareRow2, spareCol1, spareC...
    method saveWeights (line 84) | def saveWeights(self, model, mode):
    method isPivotAcceptable (line 87) | def isPivotAcceptable(self):
  function getMpsExample (line 91) | def getMpsExample():

FILE: cylp/py/pivots/DualDantzigPivot.py
  class DualDantzigPivot (line 16) | class DualDantzigPivot(DualPivotPythonBase):
    method __init__ (line 41) | def __init__(self, clpModel):
    method pivotRow (line 45) | def pivotRow(self):
    method updateWeights (line 61) | def updateWeights(self, inp, spare, spare2, updatedColumn):
    method updatePrimalSolution (line 75) | def updatePrimalSolution(self, primalUpdate, primalRatio, objectiveCha...
  function getMpsExample (line 101) | def getMpsExample():

FILE: cylp/py/pivots/DualPivotPythonBase.py
  class DualPivotPythonBase (line 7) | class DualPivotPythonBase:
    method pivotRow (line 8) | def pivotRow(self):

FILE: cylp/py/pivots/LIFOPivot.py
  class LIFOPivot (line 9) | class LIFOPivot(PivotPythonBase):
    method __init__ (line 32) | def __init__(self, clpModel):
    method pivotColumn (line 39) | def pivotColumn(self, updates, spareRow1, spareRow2, spareCol1, spareC...
    method saveWeights (line 67) | def saveWeights(self, model, mode):
    method isPivotAcceptable (line 70) | def isPivotAcceptable(self):
  function getMpsExample (line 90) | def getMpsExample():

FILE: cylp/py/pivots/MostFrequentPivot.py
  class MostFrequentPivot (line 8) | class MostFrequentPivot(PivotPythonBase):
    method __init__ (line 31) | def __init__(self, clpModel):
    method pivotColumn (line 39) | def pivotColumn(self, updates, spareRow1, spareRow2, spareCol1, spareC...
    method addFrequency (line 67) | def addFrequency(self, i):
    method saveWeights (line 80) | def saveWeights(self, model, mode):
    method isPivotAcceptable (line 83) | def isPivotAcceptable(self):
  function getMpsExample (line 87) | def getMpsExample():

FILE: cylp/py/pivots/PivotPythonBase.py
  class PivotPythonBase (line 7) | class PivotPythonBase:
    method pivotColumn (line 8) | def pivotColumn(self):
    method isPivotAcceptable (line 17) | def isPivotAcceptable(self):
    method updateReducedCosts (line 24) | def updateReducedCosts(self, updates, spareRow1, spareRow2, spareCol1,...

FILE: cylp/py/pivots/PositiveEdgePivot.py
  class PositiveEdgePivot (line 12) | class PositiveEdgePivot(PivotPythonBase):
    method __init__ (line 37) | def __init__(self, clpModel, EPSILON=10 ** (-7)):
    method updateP (line 54) | def updateP(self):
    method updateW (line 70) | def updateW(self):
    method random (line 83) | def random(self):
    method isCompatible (line 87) | def isCompatible(self, varInd):
    method checkVar (line 95) | def checkVar(self, i):
    method pivotColumn (line 98) | def pivotColumn(self, updates, spareRow1, spareRow2, spareCol1, spareC...
    method saveWeights (line 139) | def saveWeights(self, model, mode):
    method isPivotAcceptable (line 142) | def isPivotAcceptable(self):
  function getMpsExample (line 146) | def getMpsExample():

FILE: cylp/py/pivots/PositiveEdgeWolfePivot.py
  class PositiveEdgeWolfePivot (line 10) | class PositiveEdgeWolfePivot(PositiveEdgePivot):
    method __init__ (line 12) | def __init__(self, clpModel, bucketSize=1, EPSILON=10 ** (-7)):
    method pivotColumnFirst (line 16) | def pivotColumnFirst(self, updates, spareRow1, spareRow2, spareCol1, s...
    method saveWeights (line 131) | def saveWeights(self, model, mode):
    method isPivotAcceptable (line 134) | def isPivotAcceptable(self):

FILE: cylp/py/pivots/WolfePivot.py
  class WolfePivot (line 5) | class WolfePivot(PivotPythonBase):
    method __init__ (line 7) | def __init__(self, clpModel, bucketSize=1):
    method pivotColumn (line 18) | def pivotColumn(self, updates, spareRow1, spareRow2, spareCol1, spareC...
    method saveWeights (line 55) | def saveWeights(self, model, mode):
    method isPivotAcceptable (line 58) | def isPivotAcceptable(self):
    method setComplement (line 89) | def setComplement(self, model, v1, v2):

FILE: cylp/py/pivots/WolfePivotPE.py
  class WolfePivotPE (line 7) | class WolfePivotPE(PivotPythonBase):
    method __init__ (line 9) | def __init__(self, clpModel, bucketSize=1):
    method updateP (line 43) | def updateP(self):
    method updateW (line 59) | def updateW(self):
    method random (line 72) | def random(self):
    method isCompatible (line 76) | def isCompatible(self, varInd):
    method pivotColumn (line 86) | def pivotColumn(self, updates, spareRow1, spareRow2, spareCol1, spareC...
    method saveWeights (line 205) | def saveWeights(self, model, mode):
    method isPivotAcceptable (line 208) | def isPivotAcceptable(self):
    method setComplement (line 247) | def setComplement(self, model, v1, v2):

FILE: cylp/py/test_PySolve.py
  class TestPySolve (line 15) | class TestPySolve(unittest.TestCase):
    method test_pe (line 17) | def test_pe(self):
    method test_dantzig (line 21) | def test_dantzig(self):
    method test_lifo (line 25) | def test_lifo(self):
    method test_mf (line 29) | def test_mf(self):

FILE: cylp/py/utils/readSetcovering.py
  class setCover (line 8) | class setCover:
    method __init__ (line 9) | def __init__(self):
    method readWedelin (line 14) | def readWedelin(self, filename):
    method readBalas (line 36) | def readBalas(self, filename):
    method model (line 75) | def model(self):
    method QPModel (line 90) | def QPModel(self, addW=False):
    method A (line 127) | def A(self):
    method c (line 136) | def c(self):
    method G (line 146) | def G(self):

FILE: cylp/py/utils/sparseUtil.py
  class csc_matrixPlus (line 16) | class csc_matrixPlus(sparse.csc_matrix):
    method __init__ (line 17) | def __init__(self, arg1, shape=None, dtype=None,
    method __setitem__ (line 26) | def __setitem__(self, location, val):
    method addColumns (line 88) | def addColumns(self, nCol):
    method __getitem__ (line 109) | def __getitem__(self, key):
    method row_scale (line 119) | def row_scale(self, scaleFactor=None):
    method col_scale (line 139) | def col_scale(self, scaleFactor=None):
    method col_unscale (line 159) | def col_unscale(self, scaleFactor=None):
    method row_unscale (line 166) | def row_unscale(self, scaleFactor=None):
    method T (line 174) | def T(self):
    method __le__ (line 177) | def __le__(self, other):
    method __ge__ (line 182) | def __ge__(self, other):
    method __mul__ (line 187) | def __mul__(self, other):
    method __rmul__ (line 192) | def __rmul__(self, other):
    method __add__ (line 197) | def __add__(self, other):
    method __radd__ (line 202) | def __radd__(self, other):
    method __rsub__ (line 207) | def __rsub__(self, other):
    method __sub__ (line 212) | def __sub__(self, other):
    method getMatrixForTest (line 218) | def getMatrixForTest():
  class csr_matrixPlus (line 228) | class csr_matrixPlus(sparse.csr_matrix):
    method __init__ (line 229) | def __init__(self, arg1, shape=None, dtype=None,
    method __setitem__ (line 238) | def __setitem__(self, location, val):
    method addRows (line 327) | def addRows(self, nRow):
    method __getitem__ (line 348) | def __getitem__(self, key):
    method row_scale (line 358) | def row_scale(self, scaleFactor=None):
    method col_scale (line 378) | def col_scale(self, scaleFactor=None):
    method col_unscale (line 398) | def col_unscale(self, scaleFactor=None):
    method row_unscale (line 405) | def row_unscale(self, scaleFactor=None):
    method T (line 414) | def T(self):
    method __le__ (line 417) | def __le__(self, other):
    method __ge__ (line 422) | def __ge__(self, other):
    method __mul__ (line 427) | def __mul__(self, other):
    method __rmul__ (line 432) | def __rmul__(self, other):
    method __add__ (line 437) | def __add__(self, other):
    method __radd__ (line 442) | def __radd__(self, other):
    method __rsub__ (line 447) | def __rsub__(self, other):
    method __sub__ (line 452) | def __sub__(self, other):
    method getMatrixForTest (line 458) | def getMatrixForTest():
  function sparseConcat (line 467) | def sparseConcat(a, b, how, v_offset=0, h_offset=0):
  function I (line 550) | def I(n):

FILE: cylp/py/utils/util.py
  function sign (line 6) | def sign(x):
  function get_cs (line 12) | def get_cs(w1, w2):
  function givens (line 18) | def givens(n, i, j, w1, w2):
  function applyGivens (line 26) | def applyGivens(vec):
  function UH2UT (line 40) | def UH2UT(mat):
  function precondition (line 58) | def precondition(precondition, use_conditions=DEFAULT_ON):
  function postcondition (line 61) | def postcondition(postcondition, use_conditions=DEFAULT_ON):
  class conditions (line 64) | class conditions(object):
    method __init__ (line 67) | def __init__(self, pre, post, use_conditions=DEFAULT_ON):
    method __call__ (line 74) | def __call__(self, function):
  class FunctionWrapper (line 94) | class FunctionWrapper(object):
    method __init__ (line 95) | def __init__(self, precondition, postcondition, function):
    method __call__ (line 100) | def __call__(self, *args, **kwargs):
  class Ind (line 112) | class Ind:
    method __init__ (line 113) | def __init__(self, key, dim):
    method __repr__ (line 149) | def __repr__(self):
  function getIndS (line 152) | def getIndS(inds):
  function getMultiDimMatrixIndex (line 161) | def getMultiDimMatrixIndex(inds, res=[]):
  function getTupleIndex (line 176) | def getTupleIndex(ind, dims):

FILE: cylp/tests/test_CyClpSimplex.py
  class TestCyClpSimplex (line 16) | class TestCyClpSimplex(unittest.TestCase):
    method setUp (line 18) | def setUp(self):
    method test_PE (line 22) | def test_PE(self):
    method test_Dantzig (line 28) | def test_Dantzig(self):
    method test_LIFO (line 34) | def test_LIFO(self):
    method test_MostFrequent (line 40) | def test_MostFrequent(self):
    method test_initialSolve (line 46) | def test_initialSolve(self):
    method test_initialPrimalSolve (line 50) | def test_initialPrimalSolve(self):
    method test_initialDualSolve (line 54) | def test_initialDualSolve(self):
    method test_direction (line 58) | def test_direction(self):

FILE: cylp/tests/test_CyClpSimplex_CyLPModel.py
  class TestModel (line 14) | class TestModel(unittest.TestCase):
    method test (line 16) | def test(self):
    method test2 (line 47) | def test2(self):
    method test_removeConstraint (line 79) | def test_removeConstraint(self):
    method test_multiVar (line 124) | def test_multiVar(self):
    method test_onlyBounds (line 162) | def test_onlyBounds(self):
    method test_onlyBounds2 (line 181) | def test_onlyBounds2(self):
    method test_Sparse (line 200) | def test_Sparse(self):
    method test_multiDim (line 230) | def test_multiDim(self):
    method test_ArrayIndexing (line 246) | def test_ArrayIndexing(self):

FILE: cylp/tests/test_CyCoinIndexedVector.py
  class TestCyCoinIndexedVector (line 5) | class TestCyCoinIndexedVector(unittest.TestCase):
    method setUp (line 7) | def setUp(self):
    method test_basic (line 11) | def test_basic(self):
    method test_number_number (line 20) | def test_number_number(self):
    method test_slice_list_number (line 30) | def test_slice_list_number(self):
    method test_slice_list_list (line 37) | def test_slice_list_list(self):
    method test_slice_list_array (line 45) | def test_slice_list_array(self):
    method test_slice_array_number (line 53) | def test_slice_array_number(self):
    method test_slice_array_list (line 61) | def test_slice_array_list(self):
    method test_slice_array_array (line 69) | def test_slice_array_array(self):
    method test_reAssign (line 77) | def test_reAssign(self):

FILE: cylp/tests/test_CyCoinModel.py
  class TestCyCoinModel (line 5) | class TestCyCoinModel(unittest.TestCase):
    method test (line 7) | def test(self):

FILE: cylp/tests/test_CyCoinMpsIO.py
  class TestCyCoinMpsIO (line 13) | class TestCyCoinMpsIO(unittest.TestCase):
    method test (line 15) | def test(self):

FILE: cylp/tests/test_CySolve.py
  class TestPySolve (line 14) | class TestPySolve(unittest.TestCase):
    method test_dantzig (line 16) | def test_dantzig(self):

FILE: cylp/tests/test_IO.py
  class TestIO (line 8) | class TestIO(unittest.TestCase):
    method test_write (line 10) | def test_write(self):

FILE: cylp/tests/test_IndexFactory.py
  class TestIndexFactory (line 6) | class TestIndexFactory(unittest.TestCase):
    method setUp (line 8) | def setUp(self):
    method test_c1 (line 20) | def test_c1(self):
    method test_c2 (line 30) | def test_c2(self):
    method test_v1 (line 40) | def test_v1(self):
    method test_v2 (line 50) | def test_v2(self):
    method test_reverse (line 60) | def test_reverse(self):

FILE: cylp/tests/test_MIP.py
  class TestMIP (line 15) | class TestMIP(unittest.TestCase):
    method test_isInt (line 17) | def test_isInt(self):
    method test_SetInt_CopyIn (line 54) | def test_SetInt_CopyIn(self):
    method test_NodeCompare (line 104) | def test_NodeCompare(self):
    method test_multiDim (line 129) | def test_multiDim(self):
    method test_multiDim_Cbc_solve (line 148) | def test_multiDim_Cbc_solve(self):

FILE: cylp/tests/test_QP.py
  class TestQP (line 12) | class TestQP(unittest.TestCase):
    method test_1 (line 13) | def test_1(self):

FILE: cylp/tests/test_argWeightedMax.py
  class TestCyCoinIndexedVector (line 5) | class TestCyCoinIndexedVector(unittest.TestCase):
    method setUp (line 7) | def setUp(self):
    method test_argMax4_1 (line 25) | def test_argMax4_1(self):
    method test_argMax4_2 (line 29) | def test_argMax4_2(self):
    method test_argMax4_3 (line 34) | def test_argMax4_3(self):
    method test_argMax4_4 (line 39) | def test_argMax4_4(self):
    method test_argMax_5 (line 45) | def test_argMax_5(self):

FILE: cylp/tests/test_sparseUtil.py
  class TestSpaseUtil (line 7) | class TestSpaseUtil(unittest.TestCase):
    method test_scale_scale (line 10) | def test_scale_scale(self):
    method test_scale_unscale (line 21) | def test_scale_unscale(self):

FILE: cylp/tests/test_warmStart.py
  class TestModel (line 14) | class TestModel(unittest.TestCase):
    method setUp (line 16) | def setUp(self):
    method test_Variable (line 45) | def test_Variable(self):
    method test_Variable2 (line 52) | def test_Variable2(self):
    method test_Variable3 (line 59) | def test_Variable3(self):
    method test_Constraint (line 65) | def test_Constraint(self):
    method test_Constraint2 (line 71) | def test_Constraint2(self):

FILE: fixBinaries.py
  function install_name_tool (line 20) | def install_name_tool(binaryFile, lib_origin_path, lib_new_path):
  function fixBinary (line 23) | def fixBinary(file):
  function copy_in_cbc_libs (line 30) | def copy_in_cbc_libs():
  function fixAll (line 38) | def fixAll():
Copy disabled (too large) Download .json
Condensed preview — 281 files, each showing path, character count, and a content snippet. Download the .json file for the full structured content (45,275K chars).
[
  {
    "path": ".coin-or/projDesc.xml",
    "chars": 2969,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-stylesheet type = \"text/xsl\" href = \"http://www.coin-or.org/projects/autoGe"
  },
  {
    "path": ".github/workflows/ci-cvxpy.yml",
    "chars": 1921,
    "preview": "name: Integration testing with CVXPY\n\non:\n  pull_request:\n    types: [reopened, opened, synchronize]\n  push:\n  workflow_"
  },
  {
    "path": ".github/workflows/cibuildwheel.yml",
    "chars": 2680,
    "preview": "name: Build and upload to PyPI\n# taken from https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml\n\n#"
  },
  {
    "path": ".github/workflows/release.yml",
    "chars": 386,
    "preview": "---\nname: Create Release\n\non:\n  push:\n    tags:\n      - 'v*'\n\njobs:\n  create_release:\n    runs-on: ubuntu-latest\n    ste"
  },
  {
    "path": ".gitignore",
    "chars": 108,
    "preview": "*.swp\n*~\n.DS_Store\n*.o\n*.so\n*.pyc\n*.pyd\nbuild/\nMANIFEST\nCyLP.egg*\ncylp.egg-info\nsetup.cfg\ndist/\nwheelhouse/\n"
  },
  {
    "path": "AUTHORS",
    "chars": 84,
    "preview": "Mehdi Towhidi   (mehdi.towhidi@gerad.ca)\nDominique Orban (dominique.orban@gerad.ca)\n"
  },
  {
    "path": "LICENSE",
    "chars": 13850,
    "preview": "Eclipse Public License - v 2.0\r\n\r\nTHE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC\r\nLICENSE ("
  },
  {
    "path": "MANIFEST.in",
    "chars": 115,
    "preview": "include README.rst\ninclude AUTHORS\ninclude LICENSE\ninclude cylp/VERSION\nrecursive-include cylp/cpp *.hpp *.h *.cpp\n"
  },
  {
    "path": "README.rst",
    "chars": 7611,
    "preview": "CyLP\n====\n\nCyLP is a Python interface to COIN-OR’s Linear and mixed-integer program solvers\n(CLP, CBC, and CGL). CyLP’s "
  },
  {
    "path": "cylp/VERSION",
    "chars": 7,
    "preview": "0.93.0\n"
  },
  {
    "path": "cylp/__init__.py",
    "chars": 174,
    "preview": "import os\nfrom os.path import realpath, join\ncurrentDir = os.path.dirname(realpath(__file__))\nwith open(join(currentDir,"
  },
  {
    "path": "cylp/cpp/.gitignore",
    "chars": 6,
    "preview": "back/\n"
  },
  {
    "path": "cylp/cpp/CbcCompareUser.cpp",
    "chars": 3268,
    "preview": "// Copyright (C) 2004, International Business Machines\n// Corporation and others.  All Rights Reserved.\n#if defined(_MSC"
  },
  {
    "path": "cylp/cpp/CbcCompareUser.hpp",
    "chars": 2459,
    "preview": "// Copyright (C) 2002, International Business Machines\n// Corporation and others.  All Rights Reserved.\n#ifndef CbcCompa"
  },
  {
    "path": "cylp/cpp/CyClpSimplex_api.h",
    "chars": 2420,
    "preview": "#ifndef __PYX_HAVE_API__CyClpSimplex\n#define __PYX_HAVE_API__CyClpSimplex\n#include \"Python.h\"\n\nstatic void (*__pyx_f_12C"
  },
  {
    "path": "cylp/cpp/ICbc.cpp",
    "chars": 735,
    "preview": "#include \"ICbc.hpp\"\n\nICbcModel* CbcSolveMIP(IClpSimplex* clpModel, PyObject* obj, \n        runTest_t runTest, runNewSolu"
  },
  {
    "path": "cylp/cpp/ICbc.hpp",
    "chars": 609,
    "preview": "//#define NPY_NO_DEPRECATED_API\n\n#include \"CbcConfig.h\"\n\n// For Branch and bound\n#include \"OsiSolverInterface.hpp\"\n#incl"
  },
  {
    "path": "cylp/cpp/ICbcModel.cpp",
    "chars": 1275,
    "preview": "#include \"ICbcModel.hpp\"\n\n#include \"CbcCompareUser.hpp\"\n#include \"CbcSolver.hpp\"\n\nPyObject* ICbcModel::getPrimalVariable"
  },
  {
    "path": "cylp/cpp/ICbcModel.hpp",
    "chars": 1161,
    "preview": "#ifndef ICbcModel_H\n#define ICbcModel_H\n\n//#define NPY_NO_DEPRECATED_API\n\n//#include \"ClpModel.hpp\"\n#include \"ClpPackedM"
  },
  {
    "path": "cylp/cpp/ICbcNode.cpp",
    "chars": 169,
    "preview": "#include \"ICbcNode.hpp\"\n\nbool ICbcNode::breakTie(ICbcNode* y){\n    ICbcNode* x = this;\n    assert (x);\n    assert (y);\n "
  },
  {
    "path": "cylp/cpp/ICbcNode.hpp",
    "chars": 431,
    "preview": "#ifndef ICbcNode_H\n#define ICbcNode_H\n\n//#define NPY_NO_DEPRECATED_API\n\n//#include \"ClpModel.hpp\"\n#include \"ClpPackedMat"
  },
  {
    "path": "cylp/cpp/ICglCutGeneratorBase.cpp",
    "chars": 1421,
    "preview": "#include \"ICglCutGeneratorBase.h\"\n\nvoid\nCppCglCutGeneratorBase::generateCuts(const OsiSolverInterface & si, OsiCuts & cs"
  },
  {
    "path": "cylp/cpp/ICglCutGeneratorBase.h",
    "chars": 1018,
    "preview": "#include \"Python.h\"\n#include <iostream>\nusing namespace std;\n\n#include \"CglCutGenerator.hpp\"\n//#include \"CoinIndexedVect"
  },
  {
    "path": "cylp/cpp/IClpDualRowPivotBase.cpp",
    "chars": 2744,
    "preview": "#include \"IClpDualRowPivotBase.h\"\n#include \"ICoinIndexedVector.hpp\"\n\nint\nCppClpDualRowPivotBase::pivotRow()\n{\n    //std:"
  },
  {
    "path": "cylp/cpp/IClpDualRowPivotBase.h",
    "chars": 1991,
    "preview": "#include \"Python.h\"\n#include <iostream>\nusing namespace std;\n\n#include \"ClpDualRowPivot.hpp\"\n#include \"CoinIndexedVector"
  },
  {
    "path": "cylp/cpp/IClpPackedMatrix.cpp",
    "chars": 2792,
    "preview": "#include \"IClpPackedMatrix.hpp\"\n\nvoid \nIClpPackedMatrix::transposeTimesSubsetAll( IClpSimplex* model, int number,\n      "
  },
  {
    "path": "cylp/cpp/IClpPackedMatrix.hpp",
    "chars": 634,
    "preview": "#ifndef IClpPackedMatrix_H\n#define IClpPackedMatrix_H\n\n//#define NPY_NO_DEPRECATED_API\n\n//#include \"ClpModel.hpp\"\n#inclu"
  },
  {
    "path": "cylp/cpp/IClpPrimalColumnPivot.cpp",
    "chars": 844,
    "preview": "#include \"IClpPrimalColumnPivot.h\"\n\nint CppClpPrimalColumnPivotBase::pivotColumn(CoinIndexedVector * updates,\n\t\t\t  CoinI"
  },
  {
    "path": "cylp/cpp/IClpPrimalColumnPivot.h",
    "chars": 696,
    "preview": "#include \"ClpPrimalColumnPivot.hpp\"\n#include \"CoinIndexedVector.hpp\"\n#include \"Python.h\"\n\n#include <iostream>\n\ntypedef v"
  },
  {
    "path": "cylp/cpp/IClpPrimalColumnPivotBase.cpp",
    "chars": 1885,
    "preview": "#include \"IClpPrimalColumnPivotBase.h\"\n#include \"ICoinIndexedVector.hpp\"\n\nint\nCppClpPrimalColumnPivotBase::pivotColumn(C"
  },
  {
    "path": "cylp/cpp/IClpPrimalColumnPivotBase.h",
    "chars": 1347,
    "preview": "#include \"Python.h\"\n#include <iostream>\nusing namespace std;\n\n#include \"ClpPrimalColumnPivot.hpp\"\n#include \"CoinIndexedV"
  },
  {
    "path": "cylp/cpp/IClpSimplex.cpp",
    "chars": 46746,
    "preview": "#include \"IClpSimplex.hpp\"\n\n#include \"ClpSimplexDual.hpp\"\n//#include \"IClpSimplexPrimal.hpp\"\n#include \"IClpSimplexPrimal"
  },
  {
    "path": "cylp/cpp/IClpSimplex.hpp",
    "chars": 8786,
    "preview": "#ifndef IClpSimplex_H\n#define IClpSimplex_H\n\n//#define NPY_NO_DEPRECATED_API\n//#define NPY_NO_DEPRECATED_API NPY_1_7_API"
  },
  {
    "path": "cylp/cpp/IClpSimplexPrimal.cpp",
    "chars": 114765,
    "preview": "// Copyright (C) 2002, International Business Machines\n// Corporation and others.  All Rights Reserved.\n\n/* Notes on imp"
  },
  {
    "path": "cylp/cpp/IClpSimplexPrimal.hpp",
    "chars": 8186,
    "preview": "// Copyright (C) 2002, International Business Machines\n// Corporation and others.  All Rights Reserved.\n\n/*\n Authors\n\n J"
  },
  {
    "path": "cylp/cpp/IClpSimplexPrimal_Wolfe.cpp",
    "chars": 116542,
    "preview": "// Copyright (C) 2002, International Business Machines\n// Corporation and others.  All Rights Reserved.\n\n/* Notes on imp"
  },
  {
    "path": "cylp/cpp/IClpSimplexPrimal_Wolfe.hpp",
    "chars": 8017,
    "preview": "// Copyright (C) 2002, International Business Machines\n// Corporation and others.  All Rights Reserved.\n\n/* \n Authors\n \n"
  },
  {
    "path": "cylp/cpp/ICoinIndexedVector.cpp",
    "chars": 6949,
    "preview": "#include \"ICoinIndexedVector.hpp\"\n\n#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\n#include <numpy/ndarraytypes.h>\n\nIC"
  },
  {
    "path": "cylp/cpp/ICoinIndexedVector.hpp",
    "chars": 510,
    "preview": "#ifndef ICoinIndexedVector_H\n#define ICoinIndexedVector_H\n\n//#define NPY_NO_DEPRECATED_API\n\n//#include \"ClpModel.hpp\"\n#i"
  },
  {
    "path": "cylp/cpp/ICoinMP.cpp",
    "chars": 4851,
    "preview": "#include \"ICoinMP.hpp\"\n#include <stdio.h>\n\nPCOIN global_pCoin;\n\nint SOLVCALL IterCallback(int    IterCount, \n\t\t\tdouble O"
  },
  {
    "path": "cylp/cpp/ICoinMP.hpp",
    "chars": 3183,
    "preview": "#include \"IClpSimplex.hpp\"\n\n#include \"CoinHelperFunctions.hpp\"\n#include \"CoinMessageHandler.hpp\"\n\n#include \"ClpPrimalCol"
  },
  {
    "path": "cylp/cpp/ICoinModel.hpp",
    "chars": 744,
    "preview": "#ifndef ICoinModel_H\n#define ICoinModel_H\n\n//#include \"ClpModel.hpp\"\n#include \"CoinModel.hpp\"\n#include \"Python.h\"\n#inclu"
  },
  {
    "path": "cylp/cpp/ICoinMpsIO.cpp",
    "chars": 7177,
    "preview": "#include \"ICoinMpsIO.hpp\"\n\ndouble * ICoinMpsIO::IRowLower() const\n{\n  return rowlower_;\n}\ndouble * ICoinMpsIO::IRowUpper"
  },
  {
    "path": "cylp/cpp/ICoinMpsIO.hpp",
    "chars": 1539,
    "preview": "#ifndef ICoinMpsIO_H\n#define ICoinMpsIO_H\n\n//#define NPY_NO_DEPRECATED_API\n\n//#include \"ClpModel.hpp\"\n#include \"CoinMpsI"
  },
  {
    "path": "cylp/cpp/ICoinPackedMatrix.cpp",
    "chars": 1222,
    "preview": "#include \"ICoinPackedMatrix.hpp\"\n\nPyObject* ICoinPackedMatrix::np_getIndices(){\n\n\tnpy_intp dims = this->getNumElements()"
  },
  {
    "path": "cylp/cpp/ICoinPackedMatrix.hpp",
    "chars": 785,
    "preview": "#ifndef ICoinPackedMatrix_H\n#define ICoinPackedMatrix_H\n\n//#define NPY_NO_DEPRECATED_API\n\n//#include \"ClpModel.hpp\"\n#inc"
  },
  {
    "path": "cylp/cpp/IOsiCuts.cpp",
    "chars": 675,
    "preview": "#include \"IOsiCuts.hpp\"\n\nvoid\nCppOsiCuts::addColumnCut(int size, int* lowerBoundInds, double* lowerBoundElements,\n      "
  },
  {
    "path": "cylp/cpp/IOsiCuts.hpp",
    "chars": 475,
    "preview": "#include \"Python.h\"\n#include <iostream>\nusing namespace std;\n\n#include \"OsiCuts.hpp\"\n#include \"OsiSolverInterface.hpp\"\n\n"
  },
  {
    "path": "cylp/cy/.gitignore",
    "chars": 13,
    "preview": "*.html\n*.cpp\n"
  },
  {
    "path": "cylp/cy/CyCbcModel.pxd",
    "chars": 3404,
    "preview": "cimport numpy as np\nfrom cpython.ref cimport PyObject\nfrom cylp.cy.CyCgl cimport CyCglCutGenerator, CppCglCutGenerator\nf"
  },
  {
    "path": "cylp/cy/CyCbcModel.pyx",
    "chars": 10037,
    "preview": "# cython: embedsignature=True\n\nfrom itertools import product\nfrom cylp.py.mip import NodeCompareBase\nfrom cylp.py.modeli"
  },
  {
    "path": "cylp/cy/CyCbcNode.pxd",
    "chars": 399,
    "preview": "cimport numpy as np\n\ncdef extern from \"ICbcNode.hpp\":\n    cdef cppclass CppICbcNode \"ICbcNode\":\n        int depth()\n    "
  },
  {
    "path": "cylp/cy/CyCbcNode.pyx",
    "chars": 906,
    "preview": "# cython: embedsignature=True\n\ncdef class CyCbcNode:\n    def __cinit__(self):\n        self.CppSelf = new CppICbcNode()\n\n"
  },
  {
    "path": "cylp/cy/CyCgl.pxd",
    "chars": 3924,
    "preview": "cimport numpy as np\nfrom cpython.ref cimport PyObject\n\n#############################\n#Combinatorial cuts:\n##############"
  },
  {
    "path": "cylp/cy/CyCgl.pyx",
    "chars": 2996,
    "preview": "#from cylp.cy cimport CyCgl\n\n\ncdef class CyCglCutGenerator:\n    pass\n\ncdef class CyCglAllDifferent:\n    def __cinit__(se"
  },
  {
    "path": "cylp/cy/CyCglCutGeneratorBase.pxd",
    "chars": 1991,
    "preview": "from cython.operator cimport dereference as deref\ncimport cpython.ref as cpy_ref\nfrom cpython.ref cimport PyObject\nfrom "
  },
  {
    "path": "cylp/cy/CyCglCutGeneratorBase.pyx",
    "chars": 1779,
    "preview": "# cython: embedsignature=True\n\ncdef void RunGenerateCuts(void *ptr, CppOsiSolverInterface *si,\n                         "
  },
  {
    "path": "cylp/cy/CyCglTreeInfo.pxd",
    "chars": 263,
    "preview": "\ncdef extern from \"CglTreeInfo.hpp\":\n    cdef cppclass CppCglTreeInfo \"CglTreeInfo\":\n        pass\n    CppCglTreeInfo *ne"
  },
  {
    "path": "cylp/cy/CyCglTreeInfo.pyx",
    "chars": 227,
    "preview": "cdef class CyCglTreeInfo:\n    'CyCglTreeInfo documentation'\n    def __cinit__(self):\n        self.CppSelf = new CppCglTr"
  },
  {
    "path": "cylp/cy/CyClpDualRowPivotBase.pxd",
    "chars": 3891,
    "preview": "from cython.operator cimport dereference as deref\ncimport cpython.ref as cpy_ref\nfrom cpython.ref cimport PyObject\nfrom "
  },
  {
    "path": "cylp/cy/CyClpDualRowPivotBase.pyx",
    "chars": 3392,
    "preview": "# cython: profile=True\n# cython: embedsignature=True\n\nnp.import_array()\n\ncimport cylp.cy.CyClpDualRowPivotBase\n#from cyl"
  },
  {
    "path": "cylp/cy/CyClpPrimalColumnPivotBase.pxd",
    "chars": 3364,
    "preview": "from cython.operator cimport dereference as deref\ncimport cpython.ref as cpy_ref\nfrom cpython.ref cimport PyObject\nfrom "
  },
  {
    "path": "cylp/cy/CyClpPrimalColumnPivotBase.pyx",
    "chars": 2676,
    "preview": "# cython: profile=True\n# cython: embedsignature=True\n\ncimport cylp.cy.CyClpPrimalColumnPivotBase\n#from cylp.cy import Cy"
  },
  {
    "path": "cylp/cy/CyClpPrimalColumnSteepest.pyx",
    "chars": 786,
    "preview": "# cython: embedsignature=True\n\n#cimport cClpPrimalColumnSteepest\nfrom cClpPrimalColumnSteepest cimport c_ClpPrimalColumn"
  },
  {
    "path": "cylp/cy/CyClpSimplex.pxd",
    "chars": 13663,
    "preview": "# cython: embedsignature=True\n\n\nimport pyximport\npyximport.install()\n\n\ncimport cpython.ref as cpy_ref\n#from cpython.ref "
  },
  {
    "path": "cylp/cy/CyClpSimplex.pyx",
    "chars": 77815,
    "preview": "# cython: c_string_type=str, c_string_encoding=ascii\n# cython: profile=True\n# cython: embedsignature=True\n\nimport inspec"
  },
  {
    "path": "cylp/cy/CyClpSimplex_api.h",
    "chars": 2420,
    "preview": "#ifndef __PYX_HAVE_API__CyClpSimplex\n#define __PYX_HAVE_API__CyClpSimplex\n#include \"Python.h\"\n\nstatic void (*__pyx_f_12C"
  },
  {
    "path": "cylp/cy/CyCoinIndexedVector.pxd",
    "chars": 950,
    "preview": "from cpython.ref cimport PyObject\n\ncdef extern from \"ICoinIndexedVector.hpp\":\n    cdef cppclass CppCoinIndexedVector \"IC"
  },
  {
    "path": "cylp/cy/CyCoinIndexedVector.pyx",
    "chars": 1847,
    "preview": "# cython: embedsignature=True\n\ncdef class CyCoinIndexedVector:\n    '''\n    ``CyCoinIndexedVector`` interfaces ``CoinInde"
  },
  {
    "path": "cylp/cy/CyCoinModel.pxd",
    "chars": 2330,
    "preview": "cimport numpy as np\n\ncdef extern from \"CoinModel.hpp\":\n    cdef cppclass CppCoinModel \"CoinModel\":\n\n        void addRow("
  },
  {
    "path": "cylp/cy/CyCoinModel.pyx",
    "chars": 5426,
    "preview": "# cython: embedsignature=True\n\ncdef class CyCoinModel:\n    '''\n\n    >>> import numpy as np\n    >>> from cylp.cy import C"
  },
  {
    "path": "cylp/cy/CyCoinMpsIO.pxd",
    "chars": 2179,
    "preview": "from cpython.ref cimport PyObject\ncimport numpy as np\nfrom cylp.cy.CyCoinPackedMatrix cimport CyCoinPackedMatrix, CppCoi"
  },
  {
    "path": "cylp/cy/CyCoinMpsIO.pyx",
    "chars": 6769,
    "preview": "'''\nThis module interface COIN-OR's ``CoinMpsIO``. When you call\n:func:`cylp.cy.CyClpSimplex.readMps` then ``CoinMpsIO``"
  },
  {
    "path": "cylp/cy/CyCoinPackedMatrix.pxd",
    "chars": 1279,
    "preview": "from cpython.ref cimport PyObject\n\ncdef extern from \"ICoinPackedMatrix.hpp\":\n    cdef cppclass CppCoinPackedMatrix \"ICoi"
  },
  {
    "path": "cylp/cy/CyCoinPackedMatrix.pyx",
    "chars": 3463,
    "preview": "# cython: embedsignature=True\n\nimport numpy as np\ncimport numpy as np\n\n\ncdef class CyCoinPackedMatrix:\n    '''\n    ``CyC"
  },
  {
    "path": "cylp/cy/CyCutGeneratorPythonBase.pxd",
    "chars": 790,
    "preview": "from cylp.cy.CyCglCutGeneratorBase cimport *\nfrom cylp.cy.CyOsiSolverInterface cimport CppOsiSolverInterface, CyOsiSolve"
  },
  {
    "path": "cylp/cy/CyCutGeneratorPythonBase.pyx",
    "chars": 1485,
    "preview": "# cython: embedsignature=True\n\ncdef class CyCutGeneratorPythonBase(CyCglCutGeneratorBase):\n    def __init__(self, cutGen"
  },
  {
    "path": "cylp/cy/CyDantzigPivot.pxd",
    "chars": 540,
    "preview": "from cylp.cy.CyClpPrimalColumnPivotBase cimport *\nfrom cylp.cy cimport CyClpSimplex\nfrom cylp.cy.CyCoinIndexedVector cim"
  },
  {
    "path": "cylp/cy/CyDantzigPivot.pyx",
    "chars": 3585,
    "preview": "# cython: embedsignature=True\n\n\nimport numpy as np\ncimport numpy as np\n\n# varStatus defined to mimic 'enum ClpSimplex::S"
  },
  {
    "path": "cylp/cy/CyDualPivotPythonBase.pxd",
    "chars": 919,
    "preview": "import numpy as np\ncimport numpy as np\nfrom cylp.cy.CyClpDualRowPivotBase cimport *\ncimport cython.operator.dereference "
  },
  {
    "path": "cylp/cy/CyDualPivotPythonBase.pyx",
    "chars": 1986,
    "preview": "# cython: embedsignature=True\n\ncdef class CyDualPivotPythonBase(CyClpDualRowPivotBase):\n    def __init__(self, dualPivot"
  },
  {
    "path": "cylp/cy/CyOsiCuts.pxd",
    "chars": 643,
    "preview": "cimport numpy as np\nimport numpy as np\n\n\ncdef extern from \"IOsiCuts.hpp\":\n    cdef cppclass CppOsiCuts \"CppOsiCuts\":\n   "
  },
  {
    "path": "cylp/cy/CyOsiCuts.pyx",
    "chars": 2505,
    "preview": "import scipy\nfrom scipy.sparse import csr_matrix\nfrom cylp.py.modeling.CyLPModel import CyLPModel\ncimport numpy as np\nim"
  },
  {
    "path": "cylp/cy/CyOsiSolverInterface.pxd",
    "chars": 556,
    "preview": "from cylp.cy.CyClpSimplex cimport CyClpSimplex, CppIClpSimplex\n\ncdef extern from \"ClpSimplex.hpp\":\n    cdef cppclass Cpp"
  },
  {
    "path": "cylp/cy/CyOsiSolverInterface.pyx",
    "chars": 756,
    "preview": "cdef extern from *:\n    CppOsiClpSolverInterface* dynamic_cast_osi_2_clp \"dynamic_cast<OsiClpSolverInterface*>\" (CppOsiS"
  },
  {
    "path": "cylp/cy/CyPEPivot.pxd",
    "chars": 580,
    "preview": "cimport cython.operator.dereference as deref\nfrom cylp.cy.CyClpPrimalColumnPivotBase cimport *\nfrom cylp.cy cimport CyCl"
  },
  {
    "path": "cylp/cy/CyPEPivot.pyx",
    "chars": 3355,
    "preview": "# cython: embedsignature=True\n\nimport numpy as np\ncimport numpy as np\nfrom cylp.cy cimport CyPEPivot\n#from CyClpSimplex "
  },
  {
    "path": "cylp/cy/CyPivotPythonBase.pxd",
    "chars": 653,
    "preview": "from cylp.cy.CyClpPrimalColumnPivotBase cimport *\ncimport cython.operator.dereference as deref\nfrom cylp.cy.CyClpSimplex"
  },
  {
    "path": "cylp/cy/CyPivotPythonBase.pyx",
    "chars": 1807,
    "preview": "# cython: embedsignature=True\n\n\ncdef class CyPivotPythonBase(CyClpPrimalColumnPivotBase):\n    def __init__(self, pivotMe"
  },
  {
    "path": "cylp/cy/CySolve.py",
    "chars": 370,
    "preview": "import sys\nfrom cylp.cy.CyTest import CySolve\n\nif __name__ == '__main__':\n    if len(sys.argv) < 3:\n        print('Arg e"
  },
  {
    "path": "cylp/cy/CyTest.pyx",
    "chars": 718,
    "preview": "import sys\nfrom time import perf_counter\nfrom cylp.cy.CyClpSimplex cimport CyClpSimplex\nfrom cylp.cy.CyDantzigPivot cimp"
  },
  {
    "path": "cylp/cy/CyWolfePivot.pxd",
    "chars": 537,
    "preview": "from cylp.cy.CyClpPrimalColumnPivotBase cimport *\nfrom cylp.cy cimport CyClpSimplex\nfrom cylp.cy.CyCoinIndexedVector cim"
  },
  {
    "path": "cylp/cy/CyWolfePivot.pyx",
    "chars": 2712,
    "preview": "# cython: embedsignature=True\n\n\ncdef class CyWolfePivot(CyClpPrimalColumnPivotBase):\n\n    cdef pivotColumn(self, CppCoin"
  },
  {
    "path": "cylp/cy/__init__.py",
    "chars": 518,
    "preview": "from .CyCoinIndexedVector import CyCoinIndexedVector\nfrom .CyClpSimplex import CyClpSimplex\nfrom .CyCbcNode import CyCbc"
  },
  {
    "path": "cylp/cy/createCythonInterface.py",
    "chars": 1016,
    "preview": "#!/usr/bin/env python\n\n# Usage:\n# The command:\n# > python createCythonInterface.py Person\n# creates the appropriate Cyth"
  },
  {
    "path": "cylp/doc/.gitignore",
    "chars": 7,
    "preview": "build/\n"
  },
  {
    "path": "cylp/doc/Makefile",
    "chars": 4638,
    "preview": "# Makefile for Sphinx documentation\n#\n\n# You can set these variables from the command line.\nSPHINXOPTS    =\nSPHINXBUILD "
  },
  {
    "path": "cylp/doc/mathjax.py",
    "chars": 2681,
    "preview": "# -*- coding: utf-8 -*-\n\"\"\"\n    sphinx.ext.mathjax\n    ~~~~~~~~~~~~~~~~~~\n\n    Allow `MathJax <http://mathjax.org/>`_ to"
  },
  {
    "path": "cylp/doc/source/conf.py",
    "chars": 7760,
    "preview": "# -*- coding: utf-8 -*-\n#\n# cylp Documentation documentation build configuration file, created by\n# sphinx-quickstart on"
  },
  {
    "path": "cylp/doc/source/index.rst",
    "chars": 1858,
    "preview": ".. cylp Documentation documentation master file, created by\n   sphinx-quickstart on Fri Nov  4 15:54:47 2011.\n   You can"
  },
  {
    "path": "cylp/doc/source/modules/CyCbcModel.rst",
    "chars": 160,
    "preview": "===========================\n:mod:`cylp.cy.CyCbcModel`\n===========================\n\n.. automodule:: cylp.cy.CyCbcModel\n\n."
  },
  {
    "path": "cylp/doc/source/modules/CyClpSimplex.rst",
    "chars": 166,
    "preview": "===========================\n:mod:`cylp.cy.CyClpSimplex`\n===========================\n\n.. automodule:: cylp.cy.CyClpSimple"
  },
  {
    "path": "cylp/doc/source/modules/CyCoinIndexedVector.rst",
    "chars": 203,
    "preview": "===================================\n:mod:`cylp.cy.CyCoinIndexedVector`\n===================================\n\n.. automodul"
  },
  {
    "path": "cylp/doc/source/modules/CyCoinModel.rst",
    "chars": 163,
    "preview": "===========================\n:mod:`cylp.cy.CyCoinModel`\n===========================\n\n.. automodule:: cylp.cy.CyCoinModel\n"
  },
  {
    "path": "cylp/doc/source/modules/CyCoinMpsIO.rst",
    "chars": 163,
    "preview": "===========================\n:mod:`cylp.cy.CyCoinMpsIO`\n===========================\n\n.. automodule:: cylp.cy.CyCoinMpsIO\n"
  },
  {
    "path": "cylp/doc/source/modules/CyCoinPackedMatrix.rst",
    "chars": 200,
    "preview": "===================================\n:mod:`cylp.cy.CyCoinPackedMatrix`\n===================================\n\n.. automodule"
  },
  {
    "path": "cylp/doc/source/modules/CyPivotPythonBase.rst",
    "chars": 163,
    "preview": ":mod:`cylp.cy.CyPivotPythonBase`\n=====================================\n\n.. automodule:: cylp.cy.CyPivotPythonBase\n\n.. au"
  },
  {
    "path": "cylp/doc/source/modules/DantzigPivot.rst",
    "chars": 147,
    "preview": "------------------------\n:class:`DantzigPivot`\n------------------------\n\n.. automodule:: cylp.py.pivots.DantzigPivot\n\n.."
  },
  {
    "path": "cylp/doc/source/modules/DualDantzigPivot.rst",
    "chars": 163,
    "preview": "--------------------------\n:class:`DualDantzigPivot`\n--------------------------\n\n.. automodule:: cylp.py.pivots.DualDant"
  },
  {
    "path": "cylp/doc/source/modules/LIFOPivot.rst",
    "chars": 136,
    "preview": "\n----------------------\n:class:`LIFOPivot`\n----------------------\n\n.. automodule:: cylp.py.pivots.LIFOPivot\n\n.. autoclas"
  },
  {
    "path": "cylp/doc/source/modules/MostFrequentPivot.rst",
    "chars": 171,
    "preview": "----------------------------\n:class:`MostFrequentPivot`\n----------------------------\n\n.. automodule:: cylp.py.pivots.Mos"
  },
  {
    "path": "cylp/doc/source/modules/PivotPythonBase.rst",
    "chars": 171,
    "preview": "-------------------------\n:class:`PivotPythonBase`\n-------------------------\n\n.. automodule:: cylp.py.pivots.PivotPython"
  },
  {
    "path": "cylp/doc/source/modules/PositiveEdgePivot.rst",
    "chars": 172,
    "preview": "----------------------------\n:class:`PositiveEdgePivot`\n----------------------------\n\n.. automodule:: cylp.py.pivots.Pos"
  },
  {
    "path": "cylp/doc/source/modules/cy.rst",
    "chars": 306,
    "preview": "###########################\n:mod:`cylp.cy`\n###########################\n\n.. toctree::\n   :maxdepth: 1\n\n   CyClpSimplex <C"
  },
  {
    "path": "cylp/doc/source/modules/modeling.rst",
    "chars": 610,
    "preview": "============================\n:mod:`cylp.py.modeling`\n============================\n\n.. automodule:: cylp.py.modeling.CyLP"
  },
  {
    "path": "cylp/doc/source/modules/pivots.rst",
    "chars": 209,
    "preview": "==========================\n:mod:`pivots`\n==========================\n\n.. toctree::\n   :maxdepth: 1\n\n   PivotPythonBase\n  "
  },
  {
    "path": "cylp/doc/source/modules/py.rst",
    "chars": 143,
    "preview": "#############################\n:mod:`cylp.py`\n#############################\n\n.. toctree::\n   :maxdepth: 2\n\n   pivots\n   m"
  },
  {
    "path": "cylp/doc/source/modules/sparseUtil.rst",
    "chars": 653,
    "preview": "==========================\n:mod:`utils.sparseUtil`\n==========================\n\n\n.. automodule:: cylp.py.utils.sparseUtil"
  },
  {
    "path": "cylp/input/aug3dcqp.qps",
    "chars": 563344,
    "preview": "NAME          AUG3DCQP\r\nROWS\r\n  N OBJ.FUNC\r\n  E R------1\r\n  E R------2\r\n  E R------3\r\n  E R------4\r\n  E R------5\r\n  E R-"
  },
  {
    "path": "cylp/input/cvxqp1_s.qps",
    "chars": 31036,
    "preview": "NAME          CVXQP1    \r\nROWS\r\n  N OBJ.FUNC\r\n  E R------1\r\n  E R------2\r\n  E R------3\r\n  E R------4\r\n  E R------5\r\n  E "
  },
  {
    "path": "cylp/input/cvxqp2_s.qps",
    "chars": 27988,
    "preview": "NAME          CVXQP2    \r\nROWS\r\n  N OBJ.FUNC\r\n  E R------1\r\n  E R------2\r\n  E R------3\r\n  E R------4\r\n  E R------5\r\n  E "
  },
  {
    "path": "cylp/input/fileDownloader.py",
    "chars": 410,
    "preview": "import urllib\nf = urllib.urlopen(\"http://www.netlib.org/lp/data/\")\nlines = f.read().splitlines()\n\nfor line in lines:\n   "
  },
  {
    "path": "cylp/input/h.qps",
    "chars": 1393,
    "preview": "NAME          HS268\r\nROWS\r\n  N OBJ.FUNC\r\n  E R------1\r\n  E R------2\r\nCOLUMNS\r\n    C------1  OBJ.FUNC  0.183400e+05   R--"
  },
  {
    "path": "cylp/input/hs268.qps",
    "chars": 2024,
    "preview": "NAME          HS268\r\nROWS\r\n  N OBJ.FUNC\r\n  G R------1\r\n  G R------2\r\n  G R------3\r\n  G R------4\r\n  G R------5\r\nCOLUMNS\r\n"
  },
  {
    "path": "cylp/input/hs268_2.qps",
    "chars": 2011,
    "preview": "NAME          HS268\r\nROWS\r\n  N OBJ.FUNC\r\n  G R------1\r\n  E R------2\r\n  G R------3\r\n  E R------4\r\n  G R------5\r\nCOLUMNS\r\n"
  },
  {
    "path": "cylp/input/hs268_p.qps",
    "chars": 2043,
    "preview": "NAME          HS268\r\nROWS\r\n  N OBJ.FUNC\r\n  G R------1\r\n  G R------2\r\n  G R------3\r\n  G R------4\r\n  G R------5\r\nCOLUMNS\r\n"
  },
  {
    "path": "cylp/input/hs35.qps",
    "chars": 556,
    "preview": "NAME          HS35\r\nROWS\r\n  N OBJ.FUNC\r\n  G R------1\r\nCOLUMNS\r\n    C------1  OBJ.FUNC  -.800000e+01   R------1  -.100000"
  },
  {
    "path": "cylp/input/hs35_2.qps",
    "chars": 614,
    "preview": "NAME          HS35\r\nROWS\r\n  N OBJ.FUNC\r\n  G R------1\r\nCOLUMNS\r\n    C------1  OBJ.FUNC  -.100000e+01   R------1  -.100000"
  },
  {
    "path": "cylp/input/netlib/25fv47.mps",
    "chars": 366915,
    "preview": "NAME          25FV47\nROWS\n N  R0000\n E  F1X.0\n E  2SF145\n E  2SF089\n E  2SF129\n E  30M00\n E  30M94\n E  30M91\n E  30ATK\n "
  },
  {
    "path": "cylp/input/netlib/80bau3b.mps",
    "chars": 1117500,
    "preview": "NAME          80BAU3B\nROWS\n L  BCEANAUC\n L  BCNAGIUC\n L  BCNHRHUC\n L  BCNHSHUC\n L  BCWANAUC\n L  BDNMGMUC\n L  BDNMGSUC\n L"
  },
  {
    "path": "cylp/input/netlib/adlittle.mps",
    "chars": 16500,
    "preview": "NAME          ADLITTLE\nROWS\n N  .Z....\n L  ....01\n E  ....02\n L  ....03\n L  ....04\n L  ....05\n L  ....06\n L  ....07\n L  "
  },
  {
    "path": "cylp/input/netlib/afiro.mps",
    "chars": 3244,
    "preview": "NAME          AFIRO\nROWS\n E  R09\n E  R10\n L  X05\n L  X21\n E  R12\n E  R13\n L  X17\n L  X18\n L  X19\n L  X20\n E  R19\n E  R20"
  },
  {
    "path": "cylp/input/netlib/agg.mps",
    "chars": 99348,
    "preview": "NAME          AGG\nROWS\n L  CAP00101\n L  CAP00201\n L  CAP00301\n L  CAP00401\n L  CAP00501\n L  CAP00601\n L  CAP00701\n L  CA"
  },
  {
    "path": "cylp/input/netlib/agg2.mps",
    "chars": 162339,
    "preview": "NAME          AGG2\nROWS\n L  CAP00101\n L  CAP00201\n L  CAP00301\n L  CAP00401\n L  CAP00501\n L  CAP00601\n L  CAP00701\n L  C"
  },
  {
    "path": "cylp/input/netlib/agg3.mps",
    "chars": 162662,
    "preview": "NAME          AGG3\nROWS\n L  CAP00101\n L  CAP00201\n L  CAP00301\n L  CAP00401\n L  CAP00501\n L  CAP00601\n L  CAP00701\n L  C"
  },
  {
    "path": "cylp/input/netlib/ascii",
    "chars": 705,
    "preview": "Here is a list of printable ASCII characters and their hexadecimal\nvalues, plus the space character (the first one, 0x20"
  },
  {
    "path": "cylp/input/netlib/bandm.mps",
    "chars": 91165,
    "preview": "NAME          BANDM\nROWS\n N  ....1\n E  ....3\n E  ....4\n E  ....5\n E  ....6\n E  ....7\n E  ....8\n E  ...10\n E  ...11\n E  ."
  },
  {
    "path": "cylp/input/netlib/beaconfd.mps",
    "chars": 112437,
    "preview": "NAME          BEACONFD\nROWS\n N  11CSTR\n L  50022\n L  50024\n L  50028\n L  50055\n L  50059\n L  50077\n L  50080\n L  50081\n "
  },
  {
    "path": "cylp/input/netlib/blend.mps",
    "chars": 17179,
    "preview": "NAME          BLEND    BRUCE MURTAGHS BLENDING PROBLEM (MINIMIZE).\nROWS\n E  1\n E  2\n E  3\n E  4\n E  5\n E  6\n E  7\n E  8\n"
  },
  {
    "path": "cylp/input/netlib/bnl1.mps",
    "chars": 210061,
    "preview": "NAME          BNL1\nROWS\n N  OBJ\n G  CC101001\n G  CC101002\n G  CC101003\n G  CC101004\n G  CC101005\n G  CC101006\n G  CC1010"
  },
  {
    "path": "cylp/input/netlib/bnl2.mps",
    "chars": 554338,
    "preview": "NAME          BNL2\nROWS\n N  OBJ\n G  CC101001\n G  CC101003\n G  CC101005\n G  CC101006\n G  CC101008\n G  CC101011\n G  CC1010"
  },
  {
    "path": "cylp/input/netlib/boeing1.mps",
    "chars": 138507,
    "preview": "NAME          BOEING1  (FLAPINTL)\nROWS\n G  REVENUES\n G  ACOCOSTS\n N  OBJECTIV\n G  SYSTDEPT\n G  ACMILES\n G  ASMILES\n G  P"
  },
  {
    "path": "cylp/input/netlib/boeing2.mps",
    "chars": 48147,
    "preview": "NAME          BOEING2\nROWS\n G  REVENUES\n G  ACOCOSTS\n N  OBJECTIV\n L  FUELAVAL\n G  SYSTDEPT\n G  ACMILES\n G  ASMILES\n G  "
  },
  {
    "path": "cylp/input/netlib/bore3d.mps",
    "chars": 51550,
    "preview": "NAME          BORE3D\nROWS\n E  B...XI\n E  TIE.MRAR\n E  BAB...XI\n E  BAC...XI\n E  BAD...XI\n E  BAF...XI\n E  BAG...XI\n E  B"
  },
  {
    "path": "cylp/input/netlib/brandy.mps",
    "chars": 71520,
    "preview": "NAME          BRANDY\nROWS\n N  10000A\n E  10001A\n E  10002A\n E  10003A\n E  10004A\n L  10006A\n L  10007A\n E  10008A\n L  10"
  },
  {
    "path": "cylp/input/netlib/capri.mps",
    "chars": 68608,
    "preview": "NAME          CAPRI\nROWS\n E  VLRES\n N  OBJEC\n E  RAI72\n G  CVI72\n G  TRS72\n E  FPR72\n E  DEP72\n E  DEP73\n E  INV72\n E  I"
  },
  {
    "path": "cylp/input/netlib/changes",
    "chars": 3512,
    "preview": "  1 June 1987:   mpc.src added.\n  6 May 1988:    GREENBEA, GREENBEB, AGG, AGG2, AGG3 added.\n  25 June 1988:  STOCFOR1,2 "
  },
  {
    "path": "cylp/input/netlib/cycle.mps",
    "chars": 698467,
    "preview": "NAME          CYCLE\nROWS\n E  AIA.....\n E  AIB.....\n E  AIC.....\n E  AID.....\n E  AIE.....\n E  AS1.....\n E  AS2.....\n N  "
  },
  {
    "path": "cylp/input/netlib/czprob.mps",
    "chars": 485744,
    "preview": "NAME          CZPROB\nROWS\n E  .PCOST\n N  ..COST\n L  ....C3\n L  ....C4\n L  ....C5\n L  ....C6\n L  ....C7\n L  ....C8\n L  .."
  },
  {
    "path": "cylp/input/netlib/d2q06c.mps",
    "chars": 1172908,
    "preview": "NAME          D2Q06C\nROWS\n N  R0000\n L  0A0G16\n L  0A0LDX\n L  0A0S7Q\n L  0A3AUS\n L  0A3E7B\n L  0A3E8H\n L  0A3F0F\n L  0A3"
  },
  {
    "path": "cylp/input/netlib/d6cube.mps",
    "chars": 1382557,
    "preview": "NAME          D6CUBE\nROWS\n N  1\n E  2002\n E  3\n E  4\n E  5\n E  9\n E  10\n E  12\n E  14\n E  15\n E  18\n E  22\n E  28\n E  29"
  },
  {
    "path": "cylp/input/netlib/degen2.mps",
    "chars": 152758,
    "preview": "NAME          DEGEN2\nROWS\n N  OBJ.ROW\n L  CR100A\n L  CR100B\n L  CR100C\n E  SC00004\n E  SC00005\n E  SC00006\n E  SC00007\n "
  },
  {
    "path": "cylp/input/netlib/degen3.mps",
    "chars": 855781,
    "preview": "NAME          DEGEN3\nROWS\n N  OBJ.ROW\n L  CR100A\n L  CR100B\n L  CR100C\n E  SC00066\n E  SC00070\n E  SC00075\n E  SC00117\n "
  },
  {
    "path": "cylp/input/netlib/dfl001.mps",
    "chars": 1435635,
    "preview": "NAME          DFL001\nROWS\n E  R0001\n E  R0002\n E  R0003\n E  R0004\n E  R0005\n E  R0006\n E  R0007\n E  R0008\n E  R0009\n E  "
  },
  {
    "path": "cylp/input/netlib/e226.mps",
    "chars": 92230,
    "preview": "NAME          E226\nROWS\n N  ...000\n L  ...010\n E  ...011\n L  ...012\n E  ...013\n E  ...014\n E  ...015\n E  ...016\n L  ...0"
  },
  {
    "path": "cylp/input/netlib/etamacro.mps",
    "chars": 94766,
    "preview": "NAME          ETAMACRO\nROWS\n N  OPTIMALG\n E  COSTEN00\n E  COSTEN05\n E  COSTEN10\n E  COSTEN15\n E  COSTEN20\n E  COSTEN25\n "
  },
  {
    "path": "cylp/input/netlib/fffff800.mps",
    "chars": 206468,
    "preview": "NAME          FFFFF800\nROWS\n G  LVPFA\n G  LVP2A\n G  LVP3A\n G  LVPSA\n G  F.PFN\n G  F.P2N\n G  F.P3N\n G  F.PSN\n G  O.PFN\n G"
  },
  {
    "path": "cylp/input/netlib/fileDownloader.py",
    "chars": 517,
    "preview": "import urllib\nimport os\n\nf = urllib.urlopen(\"http://www.netlib.org/lp/data/\")\nlines = f.read().splitlines()\n\nfor line in"
  },
  {
    "path": "cylp/input/netlib/finnis.mps",
    "chars": 99896,
    "preview": "NAME          FINNIS   (PTABLES3)\nROWS\n N  PRICER\n G  1BALHCO\n G  1BALCOK\n G  1BALOIK\n G  1BALOIL\n G  1BALGSL\n G  1BALDS"
  },
  {
    "path": "cylp/input/netlib/fit1d.mps",
    "chars": 488679,
    "preview": "NAME          FIT1D\nROWS\n N  PENALTY\n E  CONSTANT\n L  X0000001\n L  X0000002\n G  X0000003\n G  X0000004\n G  X0000005\n G  X"
  },
  {
    "path": "cylp/input/netlib/fit1p.mps",
    "chars": 383986,
    "preview": "NAME          FIT1P\nROWS\n N  PENALTY\n E  R0000001\n E  R0000002\n E  R0000003\n E  R0000004\n E  R0000005\n E  R0000006\n E  R"
  },
  {
    "path": "cylp/input/netlib/fit2d.mps",
    "chars": 4698538,
    "preview": "NAME          FIT2D\nROWS\n N  PENALTY\n E  CONSTANT\n L  X0000001\n L  X0000002\n G  X0000003\n G  X0000004\n G  X0000005\n L  X"
  },
  {
    "path": "cylp/input/netlib/fit2p.mps",
    "chars": 2265427,
    "preview": "NAME          FIT2P\nROWS\n N  PENALTY\n E  R0000001\n E  R0000002\n E  R0000003\n E  R0000004\n E  R0000005\n E  R0000006\n E  R"
  },
  {
    "path": "cylp/input/netlib/forplan.mps",
    "chars": 156967,
    "preview": "NAME          FORPLAN  (FORPLAN1)\nROWS\n E  LC123\n N  OB1PNW20\n E  DEDO3 1R\n E  DEDO3 2R\n E  DEDO3 3R\n E  DEDO3 4R\n E  DE"
  },
  {
    "path": "cylp/input/netlib/ganges.mps",
    "chars": 280785,
    "preview": "NAME          GANGES\nROWS\n N  OBJ99\n E  CONT0101\n E  CONT0102\n E  CONT0103\n E  CONT0104\n E  CONT0105\n E  CONT0106\n E  CO"
  },
  {
    "path": "cylp/input/netlib/gfrd-pnc.mps",
    "chars": 129577,
    "preview": "NAME          GFRD-PNC\nROWS\n N  OBJ\n E  AA1\n E  AA2\n E  AB1\n E  AB2\n E  AC1\n E  AC2\n E  AH1\n E  AH2\n E  AD1\n E  AD2\n E  "
  },
  {
    "path": "cylp/input/netlib/greenbea.mps",
    "chars": 1031229,
    "preview": "NAME          GREENBEA\nROWS\n E  AAG.....\n E  AAH.....\n E  AAL.....\n E  AAM.....\n E  AAW.....\n E  AAX.....\n E  ABA.....\n "
  },
  {
    "path": "cylp/input/netlib/greenbeb.mps",
    "chars": 1031321,
    "preview": "NAME          GREENBEB\nROWS\n E  AAG.....\n E  AAH.....\n E  AAL.....\n E  AAM.....\n E  AAW.....\n E  AAX.....\n E  ABA.....\n "
  },
  {
    "path": "cylp/input/netlib/grow15.mps",
    "chars": 202806,
    "preview": "NAME          GROW15\nROWS\n N  REVENUE\n E  PRI0101\n E  PRI0201\n E  PRI0301\n E  PRI0401\n E  PRI0501\n E  PRI0601\n E  PRI070"
  },
  {
    "path": "cylp/input/netlib/grow22.mps",
    "chars": 297635,
    "preview": "NAME          GROW22\nROWS\n N  REVENUE\n E  PRI0101\n E  PRI0201\n E  PRI0301\n E  PRI0401\n E  PRI0501\n E  PRI0601\n E  PRI070"
  },
  {
    "path": "cylp/input/netlib/grow7.mps",
    "chars": 94429,
    "preview": "NAME          GROW7\nROWS\n N  REVENUE\n E  PRI0101\n E  PRI0201\n E  PRI0301\n E  PRI0401\n E  PRI0501\n E  PRI0601\n E  PRI0701"
  },
  {
    "path": "cylp/input/netlib/israel.mps",
    "chars": 80457,
    "preview": "NAME          ISRAEL\nROWS\n N  COST\n L  B1\n L  B2\n L  B3\n L  B4\n L  B5\n L  B6\n L  B7\n L  B8\n L  B9\n L  B10\n L  B11\n L  B1"
  },
  {
    "path": "cylp/input/netlib/kb2.mps",
    "chars": 10149,
    "preview": "NAME          KB2\nROWS\n N  FAT7..J.\n E  BAL...BW\n E  BHC...BW\n E  BLC...BW\n E  BLV...BW\n E  BN4...BW\n E  BP8...BW\n E  BT"
  },
  {
    "path": "cylp/input/netlib/lotfi.mps",
    "chars": 37067,
    "preview": "NAME          LOTFI\nROWS\n N  1\n E  2\n E  3\n E  4\n E  5\n E  6\n E  7\n E  8\n E  9\n E  10\n E  11\n E  12\n E  13\n E  14\n E  15"
  },
  {
    "path": "cylp/input/netlib/maros",
    "chars": 65906,
    "preview": "\nNAME          MAROS\n      847     1443       21    10006        1       42        0        0\n        1       41      86"
  },
  {
    "path": "cylp/input/netlib/maros-r7.mps",
    "chars": 4812587,
    "preview": "NAME          MAROS-R7\nROWS\n E  R1\n E  R2\n E  R3\n E  R4\n E  R5\n E  R6\n E  R7\n E  R8\n E  R9\n E  R10\n E  R11\n E  R12\n E  R"
  },
  {
    "path": "cylp/input/netlib/maros.mps",
    "chars": 328051,
    "preview": "NAME          MAROS\nROWS\n N  REVENUE1\n E  S0100110\n E  S0100210\n E  S0100260\n E  S0100330\n E  S0100400\n E  S0100810\n E  "
  },
  {
    "path": "cylp/input/netlib/minos",
    "chars": 2553,
    "preview": "                 LINEAR PROGRAMMING TEST PROBLEMS          August 1984\n\nCollected by:    Systems Optimization Laboratory"
  },
  {
    "path": "cylp/input/netlib/modszk1.mps",
    "chars": 139978,
    "preview": "NAME          MODSZK1\nROWS\n N  OBJ.FUNC\n E  ROW0002\n E  ROW0003\n E  ROW0004\n E  ROW0005\n E  ROW0006\n E  ROW0007\n E  ROW0"
  },
  {
    "path": "cylp/input/netlib/nesm.mps",
    "chars": 626813,
    "preview": "NAME          NESM\nROWS\n N  SHORTAGE\n E  RCAPP11\n E  RCAPP12\n E  RCAPP13\n E  RCAPP14\n E  RCAPP15\n E  RCAPP16\n E  RCAPP17"
  },
  {
    "path": "cylp/input/netlib/perold.mps",
    "chars": 218376,
    "preview": "NAME          PEROLD   (PILOT1)\nROWS\n E  DCOL01\n E  DCRO01\n E  DROP01\n E  DGAS01\n E  DELE01\n E  MURN01\n E  MURC01\n E  MU"
  },
  {
    "path": "cylp/input/netlib/pilot.ja.mps",
    "chars": 507693,
    "preview": "NAME          PILOT.JA\nROWS\n N  OBJ\n E  DCOL01\n E  DCRO01\n E  DROP01\n E  DGAS01\n E  DELE01\n E  MURN01\n E  MURC01\n E  MUR"
  },
  {
    "path": "cylp/input/netlib/pilot.mps",
    "chars": 1421970,
    "preview": "NAME          PILOT    (PILOTS) PILOT VERSION 1983/MOD 3    P MCALLISTER\nROWS\n N  ENDCAP\n L  BAGR01\n L  BMNG01\n L  BCON0"
  },
  {
    "path": "cylp/input/netlib/pilot.we.mps",
    "chars": 323786,
    "preview": "NAME          PILOT.WE\nROWS\n N  OBJ\n E  DCOL01\n E  DCRO01\n E  DROP01\n E  DGAS01\n E  DELE01\n E  MURN01\n E  MURC01\n E  MUR"
  },
  {
    "path": "cylp/input/netlib/pilot4.mps",
    "chars": 183731,
    "preview": "NAME          PILOT4\nROWS\n N  OBJ\n L  ECP501\n L  ECP502\n L  ECP503\n E  DCOL01\n E  DCRO01\n E  DROP01\n E  DGAS01\n E  DELE0"
  },
  {
    "path": "cylp/input/netlib/pilot87.mps",
    "chars": 2409972,
    "preview": "NAME          PILOT87\nROWS\n N  EENDCAP\n G  CCHOUS01\n G  CCHOPR01\n G  CCTRAN01\n G  CCREC101\n G  CCREC201\n G  CCCLTH01\n G "
  },
  {
    "path": "cylp/input/netlib/pilotnov.mps",
    "chars": 455205,
    "preview": "NAME          PILOTNOV (PILOTS)   INTEGRATED MODEL -- NOVEMBER 1979\nROWS\n N  OBJ\n E  DCOL01\n E  DCRO01\n E  DROP01\n E  DG"
  },
  {
    "path": "cylp/input/netlib/readme",
    "chars": 31854,
    "preview": "\n===== LP/DATA README (formerly index) =====\n\nTo reduce transmission times, linear programming test problems\nare stored "
  },
  {
    "path": "cylp/input/netlib/recipe.mps",
    "chars": 29540,
    "preview": "NAME          RECIPE\nROWS\n E  BAL...BE\n E  BCC...BE\n E  BCH...BE\n E  BCL...BE\n E  BHH...BE\n E  BHL...BE\n E  BHX...BE\n E "
  },
  {
    "path": "cylp/input/netlib/sc105.mps",
    "chars": 11164,
    "preview": "NAME          SC105\nROWS\n N  MAXIM\n L  ROW00001\n L  ROW00002\n L  ROW00003\n E  ROW00004\n E  ROW00005\n E  ROW00006\n E  ROW"
  },
  {
    "path": "cylp/input/netlib/sc205.mps",
    "chars": 21861,
    "preview": "NAME          SC205\nROWS\n N  MAXIM\n L  ROW00001\n L  ROW00002\n L  ROW00003\n E  ROW00004\n E  ROW00005\n E  ROW00006\n E  ROW"
  },
  {
    "path": "cylp/input/netlib/sc50a.mps",
    "chars": 5249,
    "preview": "NAME          SC50A\nROWS\n N  MAXIM\n L  ROW00001\n L  ROW00002\n L  ROW00003\n E  ROW00004\n E  ROW00005\n E  ROW00006\n E  ROW"
  },
  {
    "path": "cylp/input/netlib/sc50b.mps",
    "chars": 4656,
    "preview": "NAME          SC50B\nROWS\n N  MAXIM\n L  ROW00001\n L  ROW00002\n L  ROW00003\n E  ROW00004\n E  ROW00005\n E  ROW00006\n E  ROW"
  },
  {
    "path": "cylp/input/netlib/scagr25.mps",
    "chars": 75242,
    "preview": "NAME          SCAGR25\nROWS\n N  FOB00001\n E  ROW00001\n E  ROW00002\n E  ROW00003\n E  ROW00004\n E  ROW00005\n L  ROW00006\n E"
  },
  {
    "path": "cylp/input/netlib/scagr7.mps",
    "chars": 20701,
    "preview": "NAME          SCAGR7\nROWS\n N  FOB00001\n E  ROW00001\n E  ROW00002\n E  ROW00003\n E  ROW00004\n E  ROW00005\n L  ROW00006\n E "
  },
  {
    "path": "cylp/input/netlib/scfxm1.mps",
    "chars": 89706,
    "preview": "NAME          SCFXM1\nROWS\n N  .COSTA\n E  1DT001\n E  1DT002\n E  1DT003\n E  1DT004\n E  1DT005\n E  1DT006\n E  1DT007\n E  1D"
  },
  {
    "path": "cylp/input/netlib/scfxm2.mps",
    "chars": 179702,
    "preview": "NAME          SCFXM2\nROWS\n N  .COSTA\n E  1DT001\n E  1DT002\n E  1DT003\n E  1DT004\n E  1DT005\n E  1DT006\n E  1DT007\n E  1D"
  },
  {
    "path": "cylp/input/netlib/scfxm3.mps",
    "chars": 269686,
    "preview": "NAME          SCFXM3\nROWS\n N  .COSTA\n E  1DT001\n E  1DT002\n E  1DT003\n E  1DT004\n E  1DT005\n E  1DT006\n E  1DT007\n E  1D"
  },
  {
    "path": "cylp/input/netlib/scorpion.mps",
    "chars": 60285,
    "preview": "NAME          SCORPION\nROWS\n N  C9999\n G  C0361\n G  C0355\n G  C0349\n G  C0343\n G  C0337\n G  C0331\n G  C0325\n G  C0319\n G"
  },
  {
    "path": "cylp/input/netlib/scrs8.mps",
    "chars": 135725,
    "preview": "NAME          SCRS8\nROWS\n N  COST\n E  CPCOAL00\n E  CPLWRX00\n E  CPFBRX00\n E  CPADVX00\n E  CPPETG00\n E  CPSYNF00\n E  CPHT"
  }
]

// ... and 81 more files (download for full content)

About this extraction

This page contains the full source code of the coin-or/CyLP GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 281 files (62.8 MB), approximately 11.1M tokens, and a symbol index with 485 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!