forum.alglib.net

ALGLIB forum
It is currently Sat Oct 11, 2025 12:53 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  [ 2 posts ] 
Author Message
 Post subject: Minor Suggestion: Exceptions on using "conflicting" APIs
PostPosted: Tue Sep 23, 2025 9:48 pm 
Offline

Joined: Sat May 19, 2018 2:14 am
Posts: 6
The alglib APIs are growing in complexity, and it now routinely takes a dozen alglib calls to setup and run a problem. There are also APIs which really do the same thing two different ways. Specifically what I ran into is that I added minnlcsetnlc2() to a problem and forgot to delete the minnlcsetnlc() call that came later (for some reason I just slapped it below the minnlcsetbc() call without thinking too closely on what I was doing). Anyway, that led to a bunch of burned time debugging why my inequality constraints weren't working at all before I finally caught it. I have a feeling I might not be the only one to wind up debugging a bug like that. It might help users making similar mistakes to raise/throw when using two APIs that do the same thing like that. Of course some more advanced users might actually want to reuse the alglib object and fiddle with the boundary conditions extensively, including calling entirely different APIs entirely, so this would probably require adding some kind of "force" flag on the API or a "permissive"-vs-"enforcing" mode for the alglib object. But this would produce a more gradual experience for the user where they'd be protected from silly mistakes by default, and then get an exception that would point them to the right flag if they were looking to do something deliberately.


Top
 Profile  
 
 Post subject: Re: Minor Suggestion: Exceptions on using "conflicting" API
PostPosted: Mon Sep 29, 2025 12:01 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 930
Hi!

Thank you for pointing it out! Yes, there is a question of growing API - both a problem and a sign that its capabilities improve. However, that particular API, one that works with nonlinear constraints, behaves as expected: is built around "modify state" semantics. You can "set" constraints using one of two ways, you can "add" constraints (in upcoming release), you can modify constraints that were already added by rewriting them with another "set" or by "adding" something. It is done on purpose, because it allows reusing the same optimizer object when the task changes.

Sergey


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 183 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group