Category:Wren-linear

From Rosetta Code
Library
This is an example of a library. You may see a list of other libraries used on Rosetta Code at Category:Solutions by Library.

Wren-linear is a module which wraps most of the GNU Linear Programming Kit ('GLPK') for use by Wren programmers. It consists of seven classes: Glp, Prob, Smcp, Iptcp, Iocp, Tran and File. Of these Prob is the most important enabling LP/MIP problems to be solved using various methods whilst Tran provides a translator for GNU MathProg scripts. The other classes provide relevant constants, parameters or utility methods.

It is the thirty-fifth in a series of modules (listed on the language's main page) designed to assist with writing Rosetta Code tasks so the same code does not have to be written or copy/pasted time and time again thereby bloating a task's script code unnecessarily.

To use it you need to copy the Wren source code (in the talk page) to a text file called linear.wren and place this in the same directory as the importing script so the Wren-linear executable can find it.

Currently, Wren-cli does not support plug-ins though this or similar functionality is likely to be added in a future version (it's already present in DOME). Consequently, scripts using the Wren-linear module must be run under the control of a special executable whose source code (wren-linear.c) is also included (in the talk page). This executable translates Wren method calls to calls to the corresponding GLPK functions and can be built with a command line such as the following using GCC under Linux:

   $ gcc -O3 wren-linear.c -o wren-linear -lglpk -lwren -lm 

If you then want to run a script called myscript.wren you would type at the command-line:

   $ ./wren-linear myscript.wren

myscript.wren should include a line such as the following to import the classes you want to use in that particular script:

   import "./linear" for Prob, Glp

The same executable can be used to run any other Wren-linear scripts unless they require additional functionality not available in Wren itself in which case the C code will need to be suitably modified and recompiled.

GLPK is licensed under GPLv3.

Pages in category "Wren-linear"

This category contains only the following page.