Giter Club home page Giter Club logo

ampl-project's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

ampl-project's Issues

Option of `glpsol` instead of using AMPL directly

glpsol GNU MathProg is a high-level language for creating mathematical programming models. MathProg is specific to GLPK, but resembles a subset of AMPL. MathProg can also be referred to as GMPL (GNU Mathematical Programming Language), the two terms being interchangeable.

install it on Ubuntu:
sudo apt-get install glpk
as well as glpk-doc glpk-utils if needed.

And here is an help list of glpsol:

Usage: glpsol [options...] filename

General options:
   --mps             read LP/MIP problem in fixed MPS format
   --freemps         read LP/MIP problem in free MPS format (default)
   --lp              read LP/MIP problem in CPLEX LP format
   --glp             read LP/MIP problem in GLPK format 
   --math            read LP/MIP model written in GNU MathProg modeling
                     language
   -m filename, --model filename
                     read model section and optional data section from
                     filename (same as --math)
   -d filename, --data filename
                     read data section from filename (for --math only);
                     if model file also has data section, it is ignored
   -y filename, --display filename
                     send display output to filename (for --math only);
                     by default the output is sent to terminal
   --seed value      initialize pseudo-random number generator used in
                     MathProg model with specified seed (any integer);
                     if seed value is ?, some random seed will be used
   --mincost         read min-cost flow problem in DIMACS format
   --maxflow         read maximum flow problem in DIMACS format
   --simplex         use simplex method (default)
   --interior        use interior point method (LP only)
   -r filename, --read filename
                     read solution from filename rather to find it with
                     the solver
   --min             minimization
   --max             maximization
   --scale           scale problem (default)
   --noscale         do not scale problem
   -o filename, --output filename
                     write solution to filename in printable format
   -w filename, --write filename
                     write solution to filename in plain text format
   --ranges filename
                     write sensitivity analysis report to filename in
                     printable format (simplex only)
   --tmlim nnn       limit solution time to nnn seconds 
   --memlim nnn      limit available memory to nnn megabytes
   --check           do not solve problem, check input data only
   --name probname   change problem name to probname
   --wmps filename   write problem to filename in fixed MPS format
   --wfreemps filename
                     write problem to filename in free MPS format
   --wlp filename    write problem to filename in CPLEX LP format
   --wglp filename   write problem to filename in GLPK format
   --log filename    write copy of terminal output to filename
   -h, --help        display this help information and exit
   -v, --version     display program version and exit

LP basis factorization options:
   --luf             LU + Forrest-Tomlin update
                     (faster, less stable; default)
   --cbg             LU + Schur complement + Bartels-Golub update
                     (slower, more stable)
   --cgr             LU + Schur complement + Givens rotation update
                     (slower, more stable)

Options specific to simplex solver:
   --primal          use primal simplex (default)
   --dual            use dual simplex
   --std             use standard initial basis of all slacks
   --adv             use advanced initial basis (default)
   --bib             use Bixby's initial basis
   --ini filename    use as initial basis previously saved with -w
                     (disables LP presolver)
   --steep           use steepest edge technique (default)
   --nosteep         use standard "textbook" pricing
   --relax           use Harris' two-pass ratio test (default)
   --norelax         use standard "textbook" ratio test
   --presol          use presolver (default; assumes --scale and --adv)
   --nopresol        do not use presolver
   --exact           use simplex method based on exact arithmetic
   --xcheck          check final basis using exact arithmetic

Options specific to interior-point solver:
   --nord            use natural (original) ordering
   --qmd             use quotient minimum degree ordering
   --amd             use approximate minimum degree ordering (default)
   --symamd          use approximate minimum degree ordering

Options specific to MIP solver:
   --nomip           consider all integer variables as continuous
                     (allows solving MIP as pure LP)
   --first           branch on first integer variable
   --last            branch on last integer variable
   --mostf           branch on most fractional variable 
   --drtom           branch using heuristic by Driebeck and Tomlin
                     (default)
   --pcost           branch using hybrid pseudocost heuristic (may be
                     useful for hard instances)
   --dfs             backtrack using depth first search 
   --bfs             backtrack using breadth first search
   --bestp           backtrack using the best projection heuristic
   --bestb           backtrack using node with best local bound
                     (default)
   --intopt          use MIP presolver (default)
   --nointopt        do not use MIP presolver
   --binarize        replace general integer variables by binary ones
                     (assumes --intopt)
   --fpump           apply feasibility pump heuristic
   --gomory          generate Gomory's mixed integer cuts
   --mir             generate MIR (mixed integer rounding) cuts
   --cover           generate mixed cover cuts
   --clique          generate clique cuts
   --cuts            generate all cuts above
   --mipgap tol      set relative mip gap tolerance to tol

For description of the MPS and CPLEX LP formats see Reference Manual.
For description of the modeling language see "GLPK: Modeling Language
GNU MathProg". Both documents are included in the GLPK distribution.

See GLPK web page at <http://www.gnu.org/software/glpk/glpk.html>.

Please report bugs to <[email protected]>.

One short example in wikipedia is

# short example
var x1;
var x2;
maximize obj: 0.6 * x1 + 0.5 * x2;
s.t. c1: x1 + 2 * x2 <= 1;
s.t. c2: 3 * x1 + x2 <= 2;
solve;
display x1, x2;
end;

And type in shell:
glpsol --math short.mod
It will return the following output:

$ glpsol --math short.mod 
GLPSOL: GLPK LP/MIP Solver, v4.45
Parameter(s) specified in the command line:
 --math short.mod
Reading model section from short.mod...
9 lines were read
Generating obj...
Generating c1...
Generating c2...
Model has been successfully generated
GLPK Simplex Optimizer, v4.45
3 rows, 2 columns, 6 non-zeros
Preprocessing...
2 rows, 2 columns, 4 non-zeros
Scaling...
 A: min|aij| =  1.000e+00  max|aij| =  3.000e+00  ratio =  3.000e+00
Problem data seem to be well scaled
Constructing initial basis...
Size of triangular part = 2
*     0: obj =   0.000000000e+00  infeas =  0.000e+00 (0)
*     2: obj =   4.600000000e-01  infeas =  0.000e+00 (0)
OPTIMAL SOLUTION FOUND
Time used:   0.0 secs
Memory used: 0.1 Mb (114811 bytes)
Display statement at line 8
x1.val = 0.6
x2.val = 0.2
Model has been successfully processed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.