Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28502 Discussions

error occurred when I use nconf in IMSL library

Fangquan_S_
Beginner
836 Views

 used the function nconf in IMSL library to solve a constrained nonlinear optimization problem. I simplified the problem to describe the error occurred.

The objective function is log(x1 * x2 - x3 ^ 2). The constrain is x1 * x2 - x3 ^ 2 > 0. The fortran code is as followed.

program main
use IMSL

integer IBTYPE, IPRINT, M, MAXITN, ME, N
parameter (IBTYPE = 0, IPRINT = 0, M = 1, MAXITN = 100, ME = 0, N = 3)

real FVALUE, X(N), XGUESS(N), XLB(N), XSCALE(N), XUB(N)
external FCN
data XGUESS/10.0E0, 10.0E0, 2.0E0/, XSCALE/3*1.0E0/
data XLB/1.0E-6, 1.0E-6, 1E-6/, XUB/50, 50, 50/
open(44, file = "test.txt", status = "unknown")
call NCONF(FCN, M, ME, N, XGUESS, IBTYPE, XLB, XUB, XSCALE, IPRINT, MAXITN, X, FVALUE)
write(*, *) X
end program

subroutine FCN(M, ME, N, X, ACTIVE, F, G)
integer M, ME, N
real X(3), F, G(*)
logical ACTIVE(*)
ACTIVE(1) = .TRUE.
IF(ACTIVE(1)) G(1) = X(1) * x(2) - x(3) ** 2
write(44, *) x 

F = log(x(1) * x(2) - x(3) ** 2) 

write(44, *) F

return
end subroutine

When I ran the code, the constraint doesn't work. nconf do search a (x1, x2, x3) that makes x1 * x2 - x3 ^ 2 < 0.x1 * x2 - x3 ^ 2 < 0 is in the log function . It can't be negative. If the constrain works, x1 * x2 - x3 ^ 2 should not be negative.

I don't know how the nconf function search point x and how the constrain works.

 

0 Kudos
5 Replies
mecej4
Honored Contributor III
836 Views

NCONF is no longer present in IMSL6 or IMSL7, having been replaced by NNLPF/DONLP2. That said, please note that many constrained NLP algorithms do not have the property that all trial points will be located within the feasible region.

A common artifice used to overcome this problem is to compute the argument of the log(), and return a large value for f(x) if the argument is negative. There is no guarantee that this artifice will work, but it does work for your example, if you also change the starting point to, say, (2,2,1).

With these two changes, the program found  a "solution" :  (1.708291, 1.708291, 1.369381), which can be seen to be of the form x1=t, x2=t, x3=sqrt(t2-1) . However, I think that your problem is nonsensical, since you have the same expression for the constraint and the argument of the log() in the objective function. Any combination of x(1),x(2),x(3) that makes x(1)*x(2)-x(3)*x(3) approach zero will make the objective function approach log(0), that is, –infinity. Is such a solution of any use?

Please note that the argument ACTIVE to the subroutine FCN is not to be altered by user code. 

0 Kudos
Fangquan_S_
Beginner
836 Views

I know the sample don't make sense.My real objective function is a subroutine, not a mathematical formula.I simplified it to describe the error occurred.

Thank you for sharing a method  to overcome this problem.I tried this method for my real objective function. The program threw "ERROR 2 from DNCONF. The line search used more than 5 function calls, therefore it has been declared unsuccessful."  My real objective is the negative of the sum of log likelihood. It should be have a minimum.

By the way, to what extent can NNLPF/DONLP2 do better than NCONF.

Thank you.

 

 

0 Kudos
mecej4
Honored Contributor III
836 Views

It would help if you described the properties of your real objective and constraint functions.

In the meantime, the suggested remedy to try for "line search used more than 5 function calls" is to use a different set of values for Xguess.

NNLPF is more recent than NCONF. See http://www.ai7.uni-bayreuth.de/software1.htm

 

0 Kudos
Steven_L_Intel1
Employee
836 Views

I see from his post on StackOverflow that he's using IMSL 4. It might be he doesn't have NNLPF available.

0 Kudos
Fangquan_S_
Beginner
836 Views

I am trying to estimate the model in this paper. http://bura.brunel.ac.uk/bitstream/2438/905/1/02-04.pdf

The method (filter and EM algorithm) I used come from this original paper. http://www.ssc.wisc.edu/~bhansen/718/Hamilton1989.pdf

The M step is a maximization problem which can't be analytically solved. I know nconf is a minimum optimization solver. I'm using the negative of the original objective function.

My  objective function and constrains are a little complicated. I have written them into a MS word file and uploaded it.

Thank you for answering my question. 

0 Kudos
Reply