Mosel module examples
In addition to the standard installation of Mosel and Xpress Optimizer,
the environment variable MOSEL_DSO must be set to
this directory in order for Mosel to be able to locate the modules.
|
| Definition of constants of different types: Defining integer, real, string, boolean constants
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Language extensions provided by this module:
- constants: integer, real, string, boolean
This functionality can also be implemented by a package.
|
| File(s): |
myconstants.c |
| Data file(s): |
Test model myconst_test.mos |
|
|
| Definition of a procedure for getting solution values into an array: Implementing a subroutine
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Language extensions provided by this module:
Similar (less generic) functionality can be provided by a package.
|
| File(s): |
solarray.c |
| Data file(s): |
Test model solarr_test.mos |
|
|
| Definition of complex numbers and operators to work with them: Defining an external type with operators
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
Language extensions provided by this module:
- type: mathematical
- operators: arithmetic, constructors, assignment, comparator
- service: reset
|
| File(s): |
complex.c |
| Data file(s): |
Test model complex_test.mos |
|
|
| Definition of type 'task' and subroutines for accessing it: Defining an external type with operators and access routines; defining module parameters and services
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Language extensions provided by this module:
- constants: boolean
- type: collection of data
- subroutines: procedures and functions
- operators: constructors, assignment, comparator
- services: reset, accessing and enumerating parameters
- parameters: real, integer
|
| File(s): |
task.c |
| Data file(s): |
Test model task_test.mos |
|
|
| Definition of type 'date' and subroutines for accessing it: Defining an external type with operators and access routines; defining module parameters and services
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Language extensions provided by this module:
- constants: boolean
- type: system
- subroutines: procedures and functions
- operators: constructor, assignment, comparators
- services: reset, accessing and enumerating parameters
- parameter: boolean
|
| File(s): |
date.c |
| Data file(s): |
Test model date_test.mos |
|
|
| Definition of three new types and operators to work with them: Defining external types with operators
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
Language extensions provided by this module:
- types: 3 currencies
- operators: constructors, assignment (with type conversion), comparators, addition (with type conversion), multiplication with
numerical types (real,integer)
- service: reset
|
| File(s): |
euro.c |
| Data file(s): |
Test model euro_test.mos |
|
|
| Basic LP/MIP solver interface for Xpress Optimizer: Using the NI matrix handling functionality, extending a type, defining parameters and subroutines, defining a callback function
|
| |
|
| Type: |
Programming |
| Rating: |
5 (difficult) |
| Description: |
Language extensions provided by this module:
- type: extension of mpproblem
- subroutines: procedures and functions
- implementation of a callback function
- services: reset, unload, accessing and enumerating parameters
- parameters: real, integer, boolean
- constants: integer
|
| File(s): |
myxprs.c |
| Data file(s): |
Test model myxprs_test.mos |
|
|
| Basic QCQP solver interface for Xpress Optimizer: Using the mmnl matrix handling functionality, extending a type, defining parameters and subroutines, defining a callback function
|
| |
|
| Type: |
Programming |
| Rating: |
5 (difficult) |
| Description: |
Language extensions provided by this module:
- type: extension of mpproblem
- subroutines: procedures and functions
- implementation of a callback function
- services: reset, unload, accessing and enumerating parameters, module dependency
- parameters: real, integer, boolean
- constants: integer
|
| File(s): |
myqxprs.c |
| Data file(s): |
Test model catenary_mx.mos |
|
|
| Declaring a static module: Module embedded in a C program
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
Declaring a static module (the module is embedded in the
program instead of being a dso file) and initializing
an array from data stored in the C program.
The same functionality can be obtained by using I/O drivers
instead of a static module
(see second version of the program in file mmstatdsoio.c).
|
| File(s): |
mmstatdso.c, mmstatdsoio.c |
| Data file(s): |
Test model meminit.mos, Test model meminitio.mos |
|
|
| Using the 'zlib' library to provide IO driver 'compress' functionality: Defining I/O drivers
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
This example module uses the 'zlib' library (see: http://www.gzip.org) to provide the
I/O driver 'compress' (e.g. "zlib.compress:model.bim")
for stream compression and 'gzip' (e.g. "zlib.gzip:data.gz")
for handling gzip files.
Language extensions provided by this module:
|
| File(s): |
zlib.c |
|
|
| Module implementing driver 'toC' to save the compilation result to a C file: Defining an I/O driver
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
A module implementing the driver 'toC' to save the result of
a Mosel model compilation to a C file: the execution of the generated
program performs the model processing.
|
| File(s): |
export.c |
|
|
| How best to debug a module: Creating a static module
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
This program includes a module in order to compile
it as static. 'dsodbg' can then be executed from a
debugger to work on the module.
In the following lines of 'dsodbg.c'
#include "my_module.c"
#define SRC my_module
the module name (here: my_module) has to be replaced
by the name of the module to compile.
Then from a debugger one can execute:
dsodbg complex_test
to analyse the behaviour of the module. |
| File(s): |
dsodbg.c |
|
|
|