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

"exited with code 0" using UNLSF Solver

Mustafa_U_
Beginner
2,139 Views

Hello!

I have some issues using the UNLSF Solver. When I´m debugging the program stops giving me error "..XXX.exe: Native' has exited with code o (0x0)" when it is calling DUNLSF. So its not even jumping into the objective function subroutine.

Like it is described here i set IPARAM = 0, so default values should be used for IPARAM and RPARAM. Trying to CALL U4LSF to set parameters instead, didn't help either.

You can see the code below. I had to change it a little bit, so you can't see the equations in the objective functions. But i think it's not important in this case.

Fortran 77, Visual Studio 8

Any ideas, what the problem can be?

 

Thanks in advance!

 

      SUBROUTINE SUB1()
      INCLUDE 'Declaration.inc'

      INTEGER M_sp, N_sp
      PARAMETER (M_sp = 6, N_sp = 2)
      INTEGER NOUT, LDFJAC
      
      INTEGER IPARAM(6)
      

      DOUBLE PRECISION x_init_guess(N_spec),          
     &                   x_init_var(N_Spec)
     
      DOUBLE PRECISION FVEC(M_sp), FJAC(M_sp,N_sp)
      DOUBLE PRECISION XSCALE(N_sp), FSCALE(M_sp)
      REAL RPARAM(7)
      
      EXTERNAL OBJECTIVE_FUNCTION
            

      
      x_init_guess(1) = x_sp_(4)                !x_sp_ = global var.
      x_init_guess(2) = x_sp_(6)   
      
                          
      IPARAM(1) = 0
      
      !CALL U4LSF (IPARAM, RPARAM)
      CALL DUNLSF (OBJECTIVE_FUNCTION, M_sp, N_sp, x_init_guess
     &              ,XSCALE, FSCALE, IPARAM, RPARAM, x_init_var,
     &                                               FVEC, FJAC, LDFJAC)
     
      CALL UMACH (2, NOUT)
      
      END SUBROUTINE SUB1
      
      
      
      
      
      
      !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC!
      !!!!!!!!!!!OBJECTIVE FUNCTION!!!!!!!!
      
      SUBROUTINE OBJECTIVE_FUNCTION(M_sp_2, N_sp_2, 
     &                           x_init_var_2, F_)
      INCLUDE 'Declaration.inc' 
      
      INTEGER M_sp_2, N_sp_2
      DOUBLE PRECISION x_init_var_2(N_sp_2), F_(M_sp_2)
     
      
      
      x_sp_(1) = ...           
        .
        .
        .   
      x_sp_(9) = ....           
      !x_sp_(1:9) = f(x_init_var_2(1) and x_init_var_2(2)) 
      
      
               
      F_(1) = ...
        .
        .
        .
      F_(6) = ...              
      !F_(1:6) = f(x_init_var_2(1) and x_init_var_2(2) and x_sp_(1:9))
     
     
      END SUBROUTINE OBJECTIVE_FUNCTION
     
     
      
     

 

0 Kudos
5 Replies
Steven_L_Intel1
Employee
2,139 Views

"Exit with code 0" means normal termination. Showing bits and pieces of the code is not really useful when trying to help you. When you step through the program in the debugger, what's the last thing that happens before it exits?

0 Kudos
mecej4
Honored Contributor III
2,139 Views

If the call to DUNLSF contained arguments that did not satisfy IMSL's consistency check, it is not unreasonable that IMSL can terminate execution without calling your objective function subroutine -- this is usually the case when IMSL can conclude that the problem is specified inconsistently even without having to call the objective function subroutine. In other words, IMSL thinks "this problem is hopeless, no matter what the subroutine contains".

As Steve said, you need to provide full details, and avoid rushing to judgements such as "I think it's not important in this case".

0 Kudos
Mustafa_U_
Beginner
2,139 Views

Hey there,

thank you for your answers. I`m sorry, but I'm not allowed to show the full code here...

And i was sure that the cause of the problem was located in the code above. The rest of the program was working properly.

I found out what the problem was. I had to add: "LDFJAC = SIZE(FJAC,1)" and it worked! Otherwise solver doesn't know, if size of jacobian fits. Thank you for your help!

 

But a new question appeared now:

I found out that UNLSF Solver is not suitable to solve my equations. I need to add some bounds to my variables. Otherwise i get some physically meaningless solutions.

BCLSF solver allows to add bounds on the variables. The problem is that in my case the bounds are dependent on the variables itself. That means in every iteration step with changing variables, bounds would change.

I guess you can only use constant values as input for bounds using BCLSF solver, am I right? If yes: do you have any suggestions to solve this problem?

Probably calculating bounds in objective function subroutine (after starting solver), storing the actual variable vector and using both as input to start solver over and over again?

Thanks in advance for your help.

Mustafa.

0 Kudos
mecej4
Honored Contributor III
2,139 Views

Mustafa,

Your latest post in this thread illustrates the importance of something that we often stress: A problem should be clearly and completely defined and described before a program is written to solve the problem.

If you have linear constraints, use LCONF/LCONG. If you have nonlinear constraints, use NNLPF/NNLPG. For help with selecting the appropriate routine, see the section "Selection of Routines" in the IMSL-Math manual, Chapter 8.

For an excellent survey of available methods and software for optimization, see http://plato.asu.edu/guide.html .

Probably calculating bounds in objective function subroutine (after starting solver), storing the actual variable vector and using both as input to start solver over and over again?

Such ad-hoc approaches, with no mathematical basis to support them, have a high probability of failure.

0 Kudos
Mustafa_U_
Beginner
2,139 Views

Thank you very much for your answer mecej!

I will use LCONF.

Mustafa.

0 Kudos
Reply