forum.alglib.net

ALGLIB forum
It is currently Thu Mar 28, 2024 4:42 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  [ 12 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: equality condition not respected
PostPosted: Sun Feb 13, 2022 12:09 am 
Offline

Joined: Sun Feb 06, 2022 6:24 pm
Posts: 10
I am trying to solve an optimization problem with "minnlc".
The problem has 3 variables with 2 equality nonlinear conditions and boundary conditions too. I get the solution with exit code = 2, that should be the correct exit flag, but with the given results, one of the equality conditions is not zero.
Can you explain me why this is happening?


Top
 Profile  
 
 Post subject: Re: equality condition not respected
PostPosted: Mon Feb 14, 2022 7:41 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 903
1. How large is constraint violation? Small violations about 1.0E-6 in magnitude are possible and not an error.
2. What exactly solver was used? SLP, SQP, AUL?


Top
 Profile  
 
 Post subject: Re: equality condition not respected
PostPosted: Tue Feb 15, 2022 5:52 pm 
Offline

Joined: Sun Feb 06, 2022 6:24 pm
Posts: 10
The constraint violation is big, more than 1000.
The solver is SLP.


Top
 Profile  
 
 Post subject: Re: equality condition not respected
PostPosted: Tue Feb 15, 2022 9:35 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 903
Would you like to activate logging with alglib::trace_file("SLP,SQP","trace.log") call and:

1. try running SLP
2. try running SQP solver (just want to take a look from the other angle)
3. send me trace.log by email or post it here (the log does not contain sensitive information about problem being solved)


Top
 Profile  
 
 Post subject: Re: equality condition not respected
PostPosted: Wed Feb 16, 2022 10:18 pm 
Offline

Joined: Sun Feb 06, 2022 6:24 pm
Posts: 10
Hi, I have followed your instruction and uploaded here the trace file for SLP.
I am not an expert but in this file I don't see anything wrong, while from the following code:
Code:
minnlcresults(state, x0, report);
cout << report.terminationtype << endl;
cout << "condition: " << report.nlcidx << "\t" << report.nlcerr << endl;

I get in the console:
Quote:
2
condition: 0 21365.6

That mean my first nonlinear equality condition has been violated (by far).


Attachments:
trace.log [60.25 KiB]
Downloaded 106 times
Top
 Profile  
 
 Post subject: Re: equality condition not respected
PostPosted: Thu Feb 17, 2022 1:25 pm 
Offline
Site Admin

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

I see sudden spike in constraint violation between iterations #28 and #29, and the optimizer does not recover from it. There are several possible reasons why it may happen, and some of these possibilities include flaws in optimization strategy used by SLP solver. However, I wonder why such huge constraint violation occured in the first place.

How much variables do you have? Depending on variables count, would you like to define the following trace tags and run optimization again:
* if <=1000, define "SLP.DETAILED,SLP.PROBING"
* if more than 1000 variables, define "SLP.PROBING"

The SLP.DETAILED tag activates reports of locations visited and search directions. It can produce quite a long log when we have more than 1000 variables, that's why I don't ask you to define it on high-dimensional problems. The SLP.PROBING inserts additional function evaluations that allow to visualize function behavior.


Top
 Profile  
 
 Post subject: Re: equality condition not respected
PostPosted: Thu Feb 17, 2022 2:28 pm 
Offline

Joined: Sun Feb 06, 2022 6:24 pm
Posts: 10
Hi, I only have 3 variables, so I could use the detailed probing. Here the output.


Attachments:
trace.log [314.21 KiB]
Downloaded 105 times
Top
 Profile  
 
 Post subject: Re: equality condition not respected
PostPosted: Thu Feb 17, 2022 10:32 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 903
1. Can you tell me more about your constraints? They behave strangely - like at some points they are perfectly linear, and at other points nonlinearities creep in. Do you have things like min(), max(), abs() in your constraints? Or maybe if/then/else branches when computing constraint value?

2. From your log I conclude that you used ALGLIB for C++, right? (the C# uses slightly different formatting). I will prepare a modified version of SLP with better logging and one potential stability fix tomorrow and send you to e-mail that you used to register at the forum.


Top
 Profile  
 
 Post subject: Re: equality condition not respected
PostPosted: Fri Feb 18, 2022 12:01 am 
Offline

Joined: Sun Feb 06, 2022 6:24 pm
Posts: 10
Hi Sergey,
thanks for your help!

1.My constraints are partially calculated in another class and honestly quite complex. There is an abs(), but the value inside should always be positive close the solution, it could become negative only if one iteration goes very far from the solution and the initial guess.

2.Yes, I am using Alglib for C++


Top
 Profile  
 
 Post subject: Re: equality condition not respected
PostPosted: Fri Feb 18, 2022 2:46 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 903
sent!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

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