• Keine Ergebnisse gefunden

Kapitel 9 Einführung in MOPS API-Funktionen

N/A
N/A
Protected

Academic year: 2022

Aktie "Kapitel 9 Einführung in MOPS API-Funktionen"

Copied!
3
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

1

Kapitel 9

Einführung in MOPS API-Funktionen

Uwe H. Suhl

Lehrstuhl für Wirtschaftsinformatik Freie Universität Berlin

Optimierungssysteme Version 1.1 / SS 2008

MOPS - External Architecture MOPS - External Architecture

mops.dll mops.lib

convert bcdout

numérical kernels C++ / FORTRAN interface

IMR interface

punch

insert solution

save restore

tree save restore *) user programs C++ / FORTRAN user programs

VB / C# / C++, Java

input / output routines MS Excel Add-In

ClipMOPS

LP bases

IP trees

mps data

sol.

files

Load Module mops.exe

MOPS Profile Intel

MKL

user programs in AMPL

(2)

2

Einbettung von MOPS API-Funktionen in EUS Software Einbettung von MOPS API-Funktionen in EUS Software

Four principal possibilities (each in 32 Bit and 64 Bit Addressing) MOPS load module: mops.exe. Mops64.exe

ƒ Windows character executable

ƒ Data input format: mps and triplet format

ƒ Mops profile allows customizing of optimization

MOPS callable object code library: mops.lib, mops64.lib

ƒ Allows access to all internal data und functions

ƒ Model can be generated in internal arrays of optimizer

ƒ One address space with application possible

ƒ MOPS functions can only be called from compatible systems such as MS Visual C++ or Intel C++ / FORTRAN (VS6, VS2003, VS2005)

MOPS Dynamic Link Library: mops.dll, mops64.dll

ƒ DLL functions can be called from nearly all Windows programs such as Visual Basic (.NET), C#, Delphi. Java, C++ etc.

ƒ Separate address spaces of application and optimizer

ƒ Easy integration: no link step, just replace the dll if calling sequence of functions are not changed

MOPS Studio

ƒ Offers interactive modelling and optimization based on AMPL, Math. Progr. Lang.

ƒ Windows based GUI and editor for AMPL, optimization and solutions

Main MOPS Dll functions Main MOPS Dll functions

Initialize () initialization for a new model, resets parameters and values PutModel (intyp, inf, m, n, nz, ia, ja, a, lb, ub, c, typ) passes a model to the MOPS Dll 1. as triplets, 2. rowwise 3. columnwise in arrays ia,ja,lb,ub,c,typ and allocates memory for model and temporary data

Optimize (dir,status,phase,funct) solves an LP / IP model where dir is the optimization direction and the other parameters are output

SetParameter (s) where s is a string containing parameter assignments GetParameter (Parameter, value) retrieves the value of a MOPS parameter GetLPSolution (lpsta, lpFunct, Activity, RedCost, Status) stores status and values of the initial LP solution in user given arrays

GetIPSolution (ipsta, ipFunct, Activity, RedCost, Status) stores status and values of an IP-solution in user given arrays

Finish () deallocates the memory block and closes all files

Many more functions for model handling!

(3)

3

Beispiel Lösung von Sudoku-Rätseln (→ Demo) Beispiel Lösung von Sudoku-Rätseln (→ Demo)

Benutzte Funktionen in VBA unter Excel

Declare Function FreeMemory Lib "mops.dll" () As Long

Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal FileName As String) As Long Declare Function GetIPSolution Lib "mops.dll" (lipsta&, dLPfunct#, dxs#, ddj#, lsta&) As Long

Declare Function Initialize Lib "mops.dll" () As Long

Declare Function Optimize Lib "mops.dll" (ByVal ldirection&, lstatus&, lphase&, dZf#) As Long

Declare Function PutModel Lib "mops.dll" (ByVal lintyp&, ByVal inf#, ByVal m&, ByVal n&, ByVal nz&, ia&, ja&, a#, lb#, ub#, c#, typ&) As Long

Declare Function SetParameter Lib "mops.dll" (ByVal s$) As Long

Prinzip der Lösung in VBA

'PutModel Arrays für die Aufnahme des Modells

Dim intyp As Long, inf As Double, m As Long, n As Long, nz As Long Dim ia(1 To 10000) As Long, ja(1 To 10000) As Long, a(1 To 10000) As Double Dim lb(1 To 5000) As Double, ub(1 To 5000) As Double, c(1 To 5000) As Double Dim colType(1 To 5000) As Long, k As Long; Dim ColName1(1 To 5000) As Long Dim ColName2(1 To 5000) As Long; Dim ColName3(1 To 5000) As Long

…. Generate model in PutModel arrays

rc = LoadLibrary("c:\programme\mops\mops dll\mops.dll") # Pfad zur MOPS Dll rc = Initialize() # Initialisierung für ein neues Modell

rc = PutModel(intyp, inf, m, n, nz, ia(1), ja(1), a(1), lb(1), ub(1), c(1), colType(1)) # Übergabe des Modells an MOPS rc = Optimize(1, xipsta, xphase, xzbest) # Minimierung des Modells

rc = GetIPSolution(xipsta, xzbest, Activity(1), RedCost(1), ColStatus(1)) # Auslesen der Integer Lösung für VBA Rc = Finish()

Referenzen

ÄHNLICHE DOKUMENTE

(c) Zeigen Sie, dass sich alle Graphen der Schar in einem gemeinsamen Punkt schneiden.. Anleitung: Bestimmen Sie den Schnittpunkt von zwei speziellen Graphen der

The main questions concerning general boundary value problems of the form (1.2) consist in finding the appropriate Sobolev spaces (i.e. parameter- dependent norms) for which

A.: On boundary value problems for linear parabolic systems of differential equations of general form (Russian). A.: Regular degeneration and boundary layer for linear

where 7 > 0 is some number which depends on the known parameters of the problem, but not on number k.. The theorem is prooved.. When dealing with concrete problems

[r]

In this paper we prove parameter-dependent a priori estimates for mixed-order boundary value problems of rather general structure.. In partic- ular, the diagonal operators are

Ein Punkt ist nur dann zu geben, wenn genau zwei Aussagen angekreuzt sind und beide Kreuze richtig

[r]