In that case, my Visual Basic DLL has some merit :-) because it also offers a true class interface that hides/protects internal data through Properties and instance-oriented members. So, for example, this is a calling sequence for MinASA:
... Dim asa As AlgLib.MinAsaClass asa = New AlgLib.MinAsaClass(n, x, bl, bu) asa.SetCond(EpsG, EpsF, EpsX, MaxIters) Do While asa.Iteration() asa.F = f(n, asa.X) g(n, asa.X, f, asa.G, silent) Loop asa.Results(x) AlgLib.ApClass.ConsoleOutputString(testName & "#Iterations=" & asa.IterationsCount & ", #FuncEvals=" & asa.NFEV & _ ", TermType='" & AlgLib.MinAsaClass.TermTypeToString(asa.TerminationType) & "'" & _ ", #ActiveConstraints=" & asa.ActiveConstraints & vbCrLf & vbCrLf) ...
In the code above, AlgLib refers to the .NET DLL that is referenced by the test project, f(...) is an objective function to be minimized, and g(...) is a non-analytical gradient subroutine taking f() as one of its arguments. As you can see, there is no need to separately create, initialize or pass by reference the State or Result structures because they are cleanly contained in the "asa" instance. The AlgLib.MinAsaClass.TermTypeToString(asa.TerminationType) is a Shared function that returns a short description of the TerminationType (BTW, it would be great to use an enum for TerminationType).
Anyway, if there is sufficient interest in the source code, I can post it on a public share.
|