Module CuckooSearch ! Modern Fortran implementation of Cuckoo Search Optimizers. The first ! version of CS implemented is the modified Cuckoo Search algorithm ! written by Sean Walton at Swansea University and described in: ! S.Walton, O.Hassan, K.Morgan and M.R.Brown "Modified cuckoo search: A ! new gradient free optimisation algorithm" Chaos, Solitons & Fractals Vol ! 44 Issue 9, Sept 2011 pp. 710-718 DOI:10.1016/j.chaos.2011.06.004 ! MCS is based on Version 3 of Walton's MATLAB code which can be found at: ! https://code.google.com/archive/p/modified-cs/ ! Note that Walton's MATLAB code unfortunately is covered by the GPL2 license ! and as a derived work that license extends to this code ! Original license ! This program is free software: you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation, version 2. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program. If not, see . ! Other versions of CS will be added as time permits ! Written by: Dr. Richard Weed ! Center for Advanced Vehicular Systems ! Mississippi State University ! Miss. State, MS 39762 USE objectiveFunctions USE optimizerClass Implicit NONE Type, Extends(optimizer_t) :: mcs_t ! define a class for the modified Cuckoo Search Integer(IK) :: numDesVars = 1 Integer(IK) :: numTotalGens = 100 Integer(IK) :: numNestI = 100 Integer(IK) :: numDeletedEggs = 1 Integer(IK) :: minNests = 10 Integer(C_ENUM) :: flightType = YangDeb_Levy Real(RK) :: pa = 0.7_RK Real(RK) :: pwr = 0.5_RK Real(RK) :: MaxLevyStepFactor = 100._RK Logical :: constrainSearch = .TRUE. Real(RK), ALLOCATABLE :: optDesVals(:) Real(RK), ALLOCATABLE :: NestsI(:,:) Real(RK), ALLOCATABLE :: bounds(:,:) Contains Procedure :: deallocMCS Procedure :: allocMCSNestsBounds Procedure :: initMCSParams Procedure :: MCSinitNestsUser Procedure :: MCSinitNestsRandom Procedure :: MCSoptimizer Generic :: initNests => MCSinitNestsUser, MCSinitNestsRandom Generic :: optimizer => MCSoptimizer Generic :: dealloc => deallocMCS Generic :: allocNests => allocMCSNestsBounds Generic :: init => initMCSparams End Type Contains Subroutine MCSoptimizer(this, objFun) ! Objective Function can be any extension of class objective_function_t ! which requires you to define a wrapper around your actual function ! Optionally, I could have required users to pass a procedure pointer ! but I try to avoid pointers in general as much as possible Implicit NONE Class(mcs_t), Intent(INOUT) :: this Class(objective_function_t), Intent(INOUT) :: objFun ! rest of code here End Subroutine MCSoptimizer End Module CuckooSearch