I installed NLopt on my laptop (IBM ThinkPad R52, OS = Ubuntu Hardy).
        But I cannot get the Fortran interface to work. I wrote a small
        test
        code to test the installation:
         
        
        >        program test_nlopt
        >          include 'nlopt.f'
        > 
        >          integer info, algorithm
        >          integer n
        >          double precision f_data, lb(2),ub(2), x(2),minf 
        >          double precision minf_max, ftol_rel, ftol_abs
        >          double precision xtol_rel(2),xtol_abs(2), maxtime
        >          integer have_xtol_abs,maxeval
        >          integer major,minor,bugfix
        >          
        >          info=0
        >          major=0
        >          minor=0
        >          bugfix=0
        >          algorithm=nlopt_ln_newuoa
        > 
        >          n=2
        >          f_data=0.
        >          lb(1)=-Inf
        >          lb(2)=-Inf
        >          ub(1)=+Inf
        >          ub(2)=+Inf
        >          x(1)=1.
        >          x(2)=2.
        >          minf_max=-Inf
        >          ftol_rel=0.
        >          ftol_abs=0.0001
        >          xtol_rel(1)=0.
        >          xtol_rel(2)=0.
        >          xtol_abs(1)=0.
        >          xtol_abs(2)=0.
        >          have_xtol_abs=0
        >          maxeval=0
        >          maxtime=0.
        >          minf=20.
        >          call
        nloptm(info,algorithm,n,func,f_data,lb,ub,x,minf,
        >      &    minf_max,ftol_rel,ftol_abs,xtol_rel,xtol_abs, 
        >      &    have_xtol_abs,maxeval,maxtime)
        >          call nloptv(major, minor, bugfix)
        >           
        >          write(*,*) major,minor,bugfix
        >          write(*,*) info
        >          write(*,*) x,minf 
        >        end program  
        >        
        >        
        >        subroutine func(val,n,x,grad,need_gradient,f_data)
        >          double precision val
        >          integer n
        >          double precision x(n)
        >          double precision grad(n)
        >          integer need_gradient
        >          double precision f_data
        >      
        >          val=(x(1)-3.)**2+(x(2)+2.)**2
        > c         grad(1:n)=0. 
        >        end subroutine
        
        When I compile and run it I get the following output:
                   1           0           1
                  -2
           1.00000000000000        2.00000000000000
        20.0000000000000     
        
        I have tried several other values for the bounds, algorithm etc,
        but I
        always seem to get the NLOPT_INVALID_ARGS flag (info=-2). 
        Am I missing something trivial? Any help will be greatly
        appreciated.
        
        Abhi
        
        
-- 
--
Abhishek Mukherjee      
Loomis Laboratory of Physics,
University of Illinois at Urbana-Champaign,
1110 W Green St, Urbana,IL 61801


_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss

Reply via email to