Package glpk: Difference between revisions

From ApCoCoAWiki
simplified one point
m upsi!
 
Line 4: Line 4:
The basic idea behind this package is to make the linear optimization program GLPK usable in/with ApCoCoA. The package GLPK contains various functions that let you make use of the GLPK library, rather the stand-alone LP/MIP Solver glpsol.
The basic idea behind this package is to make the linear optimization program GLPK usable in/with ApCoCoA. The package GLPK contains various functions that let you make use of the GLPK library, rather the stand-alone LP/MIP Solver glpsol.


<em>Important</em>: For usage under linux, the GLPK-Program glpsol must be in the ApCoCoA package directory under <code>packages/binaries/glpk/examples/glpsol</code> and you must have the permissions to read and write in this directory. For Windows, the glsol.exe has to be in the folder <code>\packages\binaries\glpk\w64\glpsol.exe</code>. If you installed ApCoCoA-2 together with the GUI, this should already be the case.
<em>Important</em>: For usage under linux, the GLPK-Program glpsol must be in the ApCoCoA package directory under <code>packages/binaries/glpk/examples/glpsol</code> and you must have the permissions to read and write in this directory. For Windows, the glsol.exe has to be in the folder <code>packages\binaries\glpk\w64\glpsol.exe</code>. If you installed ApCoCoA-2 together with the GUI, this should already be the case.


The source code of GLPK can be downloaded at [http://www.gnu.org/software/glpk/].
The source code of GLPK can be downloaded at [http://www.gnu.org/software/glpk/].
Line 34: Line 34:
== Solving Mixed Integer Problems ==
== Solving Mixed Integer Problems ==
:''See also: [[/GLPK.MIPSolve/]]
:''See also: [[/GLPK.MIPSolve/]]
Let <math>I, J \subseteq \{1,\ldots,n\}</math> with <math>I \cap J = \emptyset</math>. If additionally, a solution <math>b = (b_1,\ldots,b_n)</math> with <math>b_i \in \mathbb{N}</math> for <math>i \in I</math> and <math>b_j \in \{0,1\}</math> for <math>j \in J</math> is searched, then one can use the function <code>[[/GLPK.MIPSolve/]]</code>. Together with <code>c</code>, <code>EQ</code>, <code>LE</code>, <code>GE</code>, <code>B</code> and <code>MinMax</code> from above, the code
Let <math>I, J \subseteq \{1,\ldots,n\}</math> be disjoint sets. If additionally, a solution <math>b = (b_1,\ldots,b_n)</math> with <math>b_i \in \mathbb{N}</math> for <math>i \in I</math> and <math>b_j \in \{0,1\}</math> for <math>j \in J</math> is searched, then one can use the function <code>[[/GLPK.MIPSolve/]]</code>. Together with <code>c</code>, <code>EQ</code>, <code>LE</code>, <code>GE</code>, <code>B</code> and <code>MinMax</code> from above, the code
<pre>GLPK.MIPSolve(c,EQ,LE,GE,B,Method,MinMax)</pre>
<pre>GLPK.MIPSolve(c,EQ,LE,GE,B,I,J,MinMax)</pre>
produces the desired solution or <code>[]</code> if the given system has no such solution.
produces the desired solution or <code>[]</code> if the given system has no such solution.


[[Category:ApCoCoA Packages]]
[[Category:ApCoCoA Packages]]
[[Category:Package glpk]]
[[Category:Package glpk]]

Latest revision as of 15:48, 1 November 2020

This article is about a function from ApCoCoA-2. If you are looking for the ApCoCoA-1 version of it, see Category:ApCoCoA-1:Package glpk.

This page describes the glpk package. For a complete list of functions, see Category:Package glpk.

The basic idea behind this package is to make the linear optimization program GLPK usable in/with ApCoCoA. The package GLPK contains various functions that let you make use of the GLPK library, rather the stand-alone LP/MIP Solver glpsol.

Important: For usage under linux, the GLPK-Program glpsol must be in the ApCoCoA package directory under packages/binaries/glpk/examples/glpsol and you must have the permissions to read and write in this directory. For Windows, the glsol.exe has to be in the folder packages\binaries\glpk\w64\glpsol.exe. If you installed ApCoCoA-2 together with the GUI, this should already be the case.

The source code of GLPK can be downloaded at [1].

Optimizing Linear Systems Of Equations

See also: GLPK.LPSolve

Let n and P=[x1,,xn]. Let f1,,fs1,g1,,gs2,h1,,hs3,cP be linear polynomials and let l1,,ln,u1,,un{,}. Let S be the system of polynomial (in)equations

{f1(b)=0fs1(b)=0g1(b)0gs2(b)0h1(b)0hs3(b)0.

Then the function GLPK.LPSolve can be used to find solution b=(b1,,bn)[l1,u1]××[ln,un] to S such that c(b)=min{c(x)x[l1,u1]××[ln,un] is a solution to S} in the following way.

  • Let EQ be the list {f1,,fs1}, let LE be the list {g1,,gs2}, and let GE be the list {h1,,hs3}.
  • Let l and u be the lists containing the upper and lower bounds for the bi with l[i]=li and u[i]=ui, if both are rational numbers. Instead of and , write l[i] = "" or u[i] = "". Set B := [ [l[1],u[1]], [l[2],u[2]], ..., [l[n],u[n]] ].
  • Choose a string Method from [ "InterP", "Simplex" ] depending on the method you want GLPK to use for solving the problem ("InterP" stands for the inter-point-method and "Simplex" for the simplex method)
  • Choose a string MinMax from [ "Min", "Max" ] depending on whether you want b to fulfill c(b)=min{c(x)x[l1,u1]××[ln,un] is a solution to S} or c(b)=max{c(x)x[l1,u1]××[ln,un] is a solution to S}.

Then call

GLPK.LPSolve(c,EQ,LE,GE,B,Method,MinMax)

to get the desired solution as a list b = [b1,...,bn] or the empty list [] if the given system of (in)equalities is unsatisfiable.

Solving Mixed Integer Problems

See also: GLPK.MIPSolve

Let I,J{1,,n} be disjoint sets. If additionally, a solution b=(b1,,bn) with bi for iI and bj{0,1} for jJ is searched, then one can use the function GLPK.MIPSolve. Together with c, EQ, LE, GE, B and MinMax from above, the code

GLPK.MIPSolve(c,EQ,LE,GE,B,I,J,MinMax)

produces the desired solution or [] if the given system has no such solution.