forum.alglib.net

ALGLIB forum
It is currently Thu Mar 28, 2024 9:02 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: ALGLIB in .NET DLL
PostPosted: Wed Jul 14, 2010 10:22 pm 
Offline

Joined: Tue Jul 06, 2010 8:00 pm
Posts: 21
I ported MinLBFGS and MinASA to a .NET DLL in Visual Basic 2010 Express. This port also includes the required base Ap and LinMin classes, as well as the test routines (with clocking) for both optimizers. I also wrote a separate GUI program that can invoke any number of ALGLIB tests from the DLL and present results, so that the DLL is extendable.

The MinLBFGS and MinASA classes present both the classic structure-oriented interface with Shared routines (so that the unit test routines can compile unchanged), as well as the modern class-oriented interface where the State and Report structures become private members of the class.

The resulting DLL is not a true Windows DLL but rather a .NET assembly. In your Visual Studio project, all you have to do is add a reference to this DLL. Then all the exported classes and routines automatically show up with correct types in the context-sensitive help in the VS editor, which hugely speeds up development.

The big benefit is that because this DLL runs on the Common Language Runtime (CLR), it should work with any other CLR-based languages, such as C#, and not just Visual Basic. In addition, unlike with the Common Object Model (COM) interface, there is no significant runtime overhead, so the code executes almost as fast as if it were statically linked to the base program. The final benefit is sharing of a single copy of the DLL among many client programs running simultaneously.

If there is interest, I can share the source code, in hope that users would port other ALGLIB modules to this DLL and share it with the community. Similarly, Sergey may take a look at this code and consider adding a translator from AlgoPascal directly to Visual Basic .NET, so that future bug fixes and enhancements are easily incorporated in this DLL.

Please express interest by replying to this post. If there are a sufficient number of requests, I will post it on some public share.


Last edited by alusr1 on Fri Jul 16, 2010 3:51 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: ALGLIB in .NET DLL
PostPosted: Wed Jul 14, 2010 11:16 pm 
Offline

Joined: Sun May 16, 2010 11:42 pm
Posts: 63
Hi alusr1 - following your earlier posts I have downloaded VB 2010 Express and bought myself a VB book, so I'm definitely interested in your dll, and especially in the source code. I don't have an awful lot of time to spend on these things, but I think I might try the ODE solver routines in VB.Net, to see how they compare with the VBA version.

_________________
Doug Jenkins
http://newtonexcelbach.wordpress.com/


Top
 Profile  
 
 Post subject: Re: ALGLIB in .NET DLL
PostPosted: Thu Jul 15, 2010 11:44 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 903
I've thought that .NET allows different languages to interoperate. So anyone can compile C# version of ALGLIB and use it from VB.NET. Am I wrong?


Top
 Profile  
 
 Post subject: Re: ALGLIB in .NET DLL
PostPosted: Thu Jul 15, 2010 1:50 pm 
Offline

Joined: Tue Jul 06, 2010 8:00 pm
Posts: 21
I have not looked at the C# version, since I never worked in that language. Does it offer class-like interface, or the classic structure-oriented interface with static (shared) routines?


Top
 Profile  
 
 Post subject: Re: ALGLIB in .NET DLL
PostPosted: Thu Jul 15, 2010 6:27 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 903
Second case. Unit = class, function = static method.


Top
 Profile  
 
 Post subject: Re: ALGLIB in .NET DLL
PostPosted: Fri Jul 16, 2010 1:13 am 
Offline

Joined: Tue Jul 06, 2010 8:00 pm
Posts: 21
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 41 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group