forum.alglib.net

ALGLIB forum
It is currently Mon Nov 04, 2024 3:10 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  [ 4 posts ] 
Author Message
 Post subject: Nonlinear Constraint Optimization Confusion
PostPosted: Mon Jun 03, 2024 6:51 pm 
Offline

Joined: Mon Jun 03, 2024 6:37 pm
Posts: 2
Hello,

I am trying to do optimization with nonlinear constraints where an algebraic representation of the function is unknown (every time it calls the function, it triggers a physical process with the given input and measurement of this process). I am trying to use the following two functions in C++, as I don't think I can get a Jacobian in this case:

void minnlcsetnlc(minnlcstate &state, const ae_int_t nlec, const ae_int_t nlic, const xparams _xparams = alglib::xdefault);


and


void minnlcoptimize(minnlcstate &state,
void (*fvec)(const real_1d_array &x, real_1d_array &fi, void *ptr),
void (*rep)(const real_1d_array &x, double func, void *ptr) = NULL,
void *ptr = NULL,
const xparams _xparams = alglib::xdefault);


However, I do not see where I can put in my nonlinear constraints in minnlcsetnlc, or anywhere in minnlcoptimize for a callback for the nonlinear constraints. How do I specify the nonlinear constraints?

Thanks for your help


Top
 Profile  
 
 Post subject: Re: Nonlinear Constraint Optimization Confusion
PostPosted: Tue Jun 04, 2024 12:29 pm 
Offline
Site Admin

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

The minnlcsetnlc/minnlcsetnlc2 pair of functions does not accept constraints themselves, merely their count and bounds/types. You should pass constraint callbacks as a part of the problem Jacobian or function vector. The first vector component / Jacobian row is an objective, the rest are constraints.

If your problem has no derivatives available, you can use numerical differentiation optimizer mode, minnlccreatef(). However, you problem is likely to be expensive to evaluate, given what you said about performing some real-world measurements every time you want to evaluate the function. ALGLIB will still work, but probably it may take too much time because every gradient evaluation means 4N physical measurements to perform.

There are other approaches, like building an RBF model of the function every time you perform a measurement, and optimize that model to determine where to evaluate the target. It allows to save a lot of time. However, presently ALGLIB does not support it.


Top
 Profile  
 
 Post subject: Re: Nonlinear Constraint Optimization Confusion
PostPosted: Fri Jun 28, 2024 8:51 pm 
Offline

Joined: Mon Jun 03, 2024 6:37 pm
Posts: 2
Hi Sergey,

Thank you for the detailed answer! I have gotten it to work, but you are right that 4N is very expensive. Is there any way alglib could do a gradient evaluation with 2N physical measurements like fmincon does in matlab? My company already has a commercial alglib license and would likely be willing to pay for this feature, or one that would use another method like building a model like you said. If alglib cannot offer this, do you know of any other package that could in C++? I was also wondering if there is a setting to increase how much alglib changes it estimates each time -- currently the behavior I am seeing is one large change at the start and then mostly small changes (there is currently not much "exploration" of the solution space compared to fmincon on the same problem).

Thanks again for your help!


Top
 Profile  
 
 Post subject: Re: Nonlinear Constraint Optimization Confusion
PostPosted: Mon Jul 01, 2024 11:10 am 
Offline
Site Admin

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

I've replied directly to your email (one that was used for registration), because some questions may require you to reveal private data about your problem. Feel free to repost answers here, if you want!


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 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