#!/usr/bin/env bash

# Exit when command fails
set -e
#Attempt to use undefined variable outputs error message, and forces an exit
set -u
#Causes a pipeline to return the exit status of the last command in the pipe
#that returned a non-zero return value.
set -o pipefail
#set -x

source $COINBREW_HOME/scripts/generate_readme

pushd . > /dev/null
cd $(dirname $0)
SCRIPT_DIR=$PWD
popd > /dev/null

create_variables $SCRIPT_DIR/config.yml

make_header

echo "Clp (*C*oin-or *l*inear *p*rogramming) is an open-source linear programming solver.
It is primarily meant to be used as a callable library, but a basic, stand-alone executable version is also available.
It is designed to find solutions of mathematical optimization problems of the form

minimize   c'x
such that  lhs &le; Ax &le; rhs
and        lb &le; x &le; ub


CLP includes primal and dual Simplex solvers.
Both dual and primal algorithms can use matrix storage methods provided by the user (0-1 and network matrices are already supported in addition to the default sparse matrix).
The dual algorithm has Dantzig and Steepest edge row pivot choices; new ones may be provided by the user.
The same is true for the column pivot choice of the primal algorithm.
The primal can also use a non linear cost which should work for piecewise linear convex functions.
CLP also includes a barrier method for solving LPs.
"

make_build_info

echo "### With Microsoft Visual Studio

For Microsoft Visual C++ users, there are project files for version 10
available in the \`MSVisualStudio\` directory. First, obtain the source code
using either a Windows git client or download a snapshot. In MSVC++ Version
10, open the solution file (this should be converted to whatever version of
MSVC+ you are using) and build the Clp project. The code should build out of
the box with default settings.

It is also possible to build Clp with the Visual Studio compiler from the
command line using the procedure for Unix-like environments, using the Msys2
shell or CYGWIN. This is the recommended and best-supported way of building
Clp in Windows from source. To do so, make sure the \`cl\` compiler is in your
path and add \`--enable-msvc\` to build command of \`coinbrew\`.  

## Quick start

Running clp gives you some hints.  It can do a unit test (\`clp -unitTest\`) and solve netlib 
problems (\`-netlib\` or \`-netlibp\` using primal).  It can also solve problems and set tolerances
etc.  Just do 
\`\`\`
clp 
\`\`\` 
and then try \`?\` or setting various stuff.

\`\`\`
clp filename                #read file, do presolve and dual algorithm
clp filename -primalsimplex #use primal instead
\`\`\`
On Linux, clp can do file completion and line editing if it can find the 
history, readline, and termcap packages when building.

If you want to stress the code, you can set various stuff, e.g., dantzig pricing
and then go into netlib testing.  It is not guaranteed that it will solve all 
netlib instances if you get too creative.  For instance using presolve makes 
netlib solve faster - but pilot87 prefers a large infeasibility weight.  So
\`\`\`
clp -presolve on -dualbound 1.0e10 -netlib
\`\`\`
works well.

There are examples in [examples](examples).  To create an executable, build 
with \`coinbrew\` as above and then do
\`\`\`
cd build/Cbc/$version_num/examples
make DRIVER=minimum #build the driver minimum.cpp
\`\`\`
or whichever driver you want.  A list is in [Makefile](Makefile.in).
Three useful samples are:

 * \`minimum.cpp\` This is the simplest possible program to read an mps file.

 * \`defaults.cpp\`.  This does not do much more, but it does it in much more 
complicated way by specifically setting defaults so it does give more
useful information.  It also prints a solution in a format "similar" to that
of MPSX.

 * \`presolve.cpp\`  This is a good driver for larger problems.

Other ones can get complicated so start simple and work your way up.
"

make_doxygen_info

echo "## Project Links

Help:
 * [Code of Conduct](https://www.coin-or.org/code-of-conduct/)
 * [Discussion forum](https://github.com/coin-or/Clp/discussions)
 * [Report a bug](https://github.com/coin-or/Clp/issues/new)
 
Documentation:
 * [Doxygen-generated html documentation](https://coin-or.github.io/Clp/Doxygen)
 * Source code [examples](examples/)
 * [User's Guide](https://coin-or.github.io/Clp) (from 2004)

Interfaces:
 * [Matlab Interface + Windows x86 & x64 Interface Binaries (OPTI Toolbox)](https://www.inverseproblem.co.nz/OPTI/)
 * [Julia interface](https://github.com/JuliaOpt/Clp.jl)
 * [R and CLP - a quick start](https://cran.r-project.org/web/packages/clpAPI/vignettes/clpAPI.pdf)
 * [Java and CLP - performs well](http://orinanobworld.blogspot.co.uk/2016/06/using-clp-with-java.html)
" 





