@@ -585,6 +585,38 @@ def test_solve_gsl_function_const_arg(self):
585585 res = opt .solve (model , tee = True )
586586 self .assertAlmostEqual (value (model .x ), 0.1 , 5 )
587587
588+ @unittest .skipIf (
589+ not check_available_solvers ('ipopt_v2' ),
590+ "The 'ipopt_v2' solver is not available" ,
591+ )
592+ def test_solve_gsl_function (self ):
593+ DLL = find_GSL ()
594+ if not DLL :
595+ self .skipTest ("Could not find the amplgsl.dll library" )
596+ model = ConcreteModel ()
597+ model .z_func = ExternalFunction (library = DLL , function = "gsl_sf_gamma" )
598+ model .x = Var (initialize = 3 , bounds = (1e-5 , None ))
599+ model .o = Objective (expr = model .z_func (model .x ))
600+ opt = SolverFactory ('ipopt_v2' )
601+ res = opt .solve (model , tee = True )
602+ self .assertAlmostEqual (value (model .o ), 0.885603194411 , 7 )
603+
604+ @unittest .skipIf (
605+ not check_available_solvers ('ipopt_v2' ),
606+ "The 'ipopt_v2' solver is not available" ,
607+ )
608+ def test_solve_gsl_function_const_arg (self ):
609+ DLL = find_GSL ()
610+ if not DLL :
611+ self .skipTest ("Could not find the amplgsl.dll library" )
612+ model = ConcreteModel ()
613+ model .z_func = ExternalFunction (library = DLL , function = "gsl_sf_beta" )
614+ model .x = Var (initialize = 1 , bounds = (0.1 , None ))
615+ model .o = Objective (expr = - model .z_func (1 , model .x ))
616+ opt = SolverFactory ('ipopt_v2' )
617+ res = opt .solve (model , tee = True )
618+ self .assertAlmostEqual (value (model .x ), 0.1 , 5 )
619+
588620 @unittest .skipIf (
589621 not check_available_solvers ('ipopt' ), "The 'ipopt' solver is not available"
590622 )
0 commit comments