########################## Julia 0.6 GATEWAY ########################### # # _| _| _|_|_| _|_|_| _|_| _|_|_| _|_| # _|_| _|_| _| _| _| _| _| _| _| _| # _| _| _| _| _| _| _|_|_|_| _| _| _| # _| _| _| _| _| _| _| _| _| _| # _| _| _|_|_| _|_|_| _| _| _|_|_| _|_| # # Version 6.0 # ######################################################################## # # See the MIDACO user manual for detailed information # ######################################################################## # # Author (C) : Dr. Martin Schlueter # Information Initiative Center, # Division of Large Scale Computing Systems, # Hokkaido University, JAPAN. # # Email : info@midaco-solver.com # # URL : http://www.midaco-solver.com # ######################################################################## function midaco( problem, option, key ) ######################################################################## # ___ ___ _ # # | _ \_ _ ___ __ ___ ______ |_ _|_ _ _ __ _ _| |_ # # | _/ '_/ _ \/ _/ -_|_-<_-< | || ' \| '_ \ || | _| # # |_| |_| \___/\__\___/__/__/ |___|_||_| .__/\_,_|\__| # # |_| # ######################################################################## o =problem["o"] n =problem["n"] ni=problem["ni"] m =problem["m"] me=problem["me"] xl=Array{Float64}(n) xu=Array{Float64}(n) x=Array{Float64}(n) for i=1:n xl[i]=problem["xl"][i] xu[i]=problem["xu"][i] x[i]=problem["x"][i] end maxeval=option["maxeval"] maxtime=option["maxtime"] printeval=option["printeval"] save2file=option["save2file"] param=Array{Float64}(13) param[ 1] = option["param1"] param[ 2] = option["param2"] param[ 3] = option["param3"] param[ 4] = option["param4"] param[ 5] = option["param5"] param[ 6] = option["param6"] param[ 7] = option["param7"] param[ 8] = option["param8"] param[ 9] = option["param9"] param[10] = option["param10"] param[11] = option["param11"] param[12] = option["param12"] param[13] = option["param13"] PARALLEL = option["parallel"] if PARALLEL <= 1 p = 1 else p = PARALLEL end lrw=120*n+20*m+20*o+20*p+p*(m+2*o)+o*o+5000 lpf=1000*(o+m+n)+1+100 custom_LPF = param[10] if custom_LPF >= 1.0 lpf = Int(floor(custom_LPF))*(o+m+n)+1+100 end if custom_LPF <=-1.0 lpf = -Int(floor(custom_LPF))*(o+m+n)+1+100 end rw=Array{Float64}(lrw) pf=Array{Float64}(lpf) iflag=0 istop=0 tmparray = Array{Float64}(15) tmparray[1] = p tmparray[2] = o tmparray[3] = n tmparray[4] = ni tmparray[5] = m tmparray[6] = me tmparray[7] = iflag tmparray[8] = istop tmparray[9] = lrw tmparray[10] = 1.0 tmparray[11] = lpf tmparray[12] = maxeval tmparray[13] = maxtime tmparray[14] = printeval tmparray[15] = save2file f=Array{Float64}(o) g=Array{Float64}(m) if p <= 1 # SERIAL CASE ########################################################################## # ___ _ _ _ _ _ _ # # / _ \ _ __| |_(_)_ __ (_)_____ _| |_(_)___ _ _ | | ___ ___ _ __ # # | (_) | '_ \ _| | ' \| |_ / _` | _| / _ \ ' \ | |__/ _ \/ _ \ '_ \ # # \___/| .__/\__|_|_|_|_|_/__\__,_|\__|_\___/_||_| |____\___/\___/ .__/ # # |_| |_| # ########################################################################## midacoLIB(tmparray,x,f,g,xl,xu,param,rw,pf,key) iflag=tmparray[7] istop=tmparray[8] while istop <= 0 f,g = problem_function(x) # Call to OPTIMIZATION PROBLEM tmparray[10] = 0.0 midacoLIB(tmparray,x,f,g,xl,xu,param,rw,pf,key) iflag=tmparray[7] istop=tmparray[8] tmparray[10] = 2.0 midacoLIB(tmparray,x,f,g,xl,xu,param,rw,pf,key) iflag=tmparray[7] istop=tmparray[8] end end if p >= 2 # PARALLEL CASE ########################################################################## # ___ _ _ _ _ _ _ # # / _ \ _ __| |_(_)_ __ (_)_____ _| |_(_)___ _ _ | | ___ ___ _ __ # # | (_) | '_ \ _| | ' \| |_ / _` | _| / _ \ ' \ | |__/ _ \/ _ \ '_ \ # # \___/| .__/\__|_|_|_|_|_/__\__,_|\__|_\___/_||_| |____\___/\___/ .__/ # # |_| |_| # ########################################################################## fff=SharedArray{Float64}(o*p) ggg=SharedArray{Float64}(m*p) xxx=SharedArray{Float64}(n*p) # Copy stating point X into XXX array for c = 1:p for i=1:n xxx[n*(c-1)+i] = x[i] end end midacoLIB(tmparray,xxx,fff,ggg,xl,xu,param,rw,pf,key) iflag=tmparray[7] istop=tmparray[8] while istop <= 0 #----------------------------------------------PARALLEL-LOOP-START @sync @parallel for c = 1:p for i=1:n x[i] = xxx[n*(c-1)+i] # Get X from XXX array end f,g = problem_function(x) # Call to OPTIMIZATION PROBLEM for i=1:o fff[o*(c-1)+i] = f[i] # Store F in FFF array end for i=1:m ggg[m*(c-1)+i] = g[i] # Store G in GGG array end end #------------------------------------------------PARALLEL-LOOP-END tmparray[10] = 0.0 midacoLIB(tmparray,xxx,fff,ggg,xl,xu,param,rw,pf,key) iflag=tmparray[7] istop=tmparray[8] tmparray[10] = 2.0 midacoLIB(tmparray,xxx,fff,ggg,xl,xu,param,rw,pf,key) iflag=tmparray[7] istop=tmparray[8] end end ######################################################################## ######################################################################## ######################################################################## ### ___ _ ___ _ _ _ ### ### | _ \___| |_ _ _ _ _ _ _ / __| ___| |_ _| |_(_)___ _ _ ### ### | / -_) _| || | '_| ' \ \__ \/ _ \ | || | _| / _ \ ' \ ### ### |_|_\___|\__|\_,_|_| |_||_| |___/\___/_|\_,_|\__|_\___/_||_| ### ### ### ######################################################################## ######################################################################## ######################################################################## solution = Dict() solution["f"] = f solution["g"] = g solution["x"] = x solution["iflag"] = iflag solution["pareto"] = pf[1] # Number of pareto points (stored in pf[1]) solution["pf"] = pf # Full array containing the entire PARETO FRONT data return solution ######################################################################## ######################################################################## ######################################################################## end # END OF GATEWAY ######################################################################### # __ __ ___ ___ _ ___ ___ _ _ _ # # | \/ |_ _| \ /_\ / __/ _ \ ___ | | (_) |__ _ _ __ _ _ _ _ _ # # | |\/| || || |) / _ \ (_| (_) | |___| | |__| | '_ \ '_/ _` | '_| || | # # |_| |_|___|___/_/ \_\___\___/ |____|_|_.__/_| \__,_|_| \_, | # # |__/ # ######################################################################### # This function calls the midacoJL.dll library file. By default, # # the library file is loaded from the current working directory: # # # # ".\\midacoJL.dll" (Windows) # # # # "./midacoJL.dll" (Mac and Linux) # # # # Alternatively, users may enter the path manually, like this: # # # # Windows example path: # # # # "C:\\Users\\username\\Desktop\\midacoJL.dll" # # # # Mac example path: # # # # "/Users/username/Desktop/midacoJL.dll" # # # # Linux example path: # # # # "/home/username/Desktop/midacoJL.dll" # # # ######################################################################### function midacoLIB( tmparray,x,f,g,xl,xu,param,rw,pf,key ) if is_windows() ccall((:midacoJL,".\\midacoJL.dll"), Void,(Ref{Cdouble},Ref{Cdouble},Ref{Cdouble},Ref{Cdouble}, Ref{Cdouble},Ref{Cdouble},Ref{Cdouble},Ref{Cdouble}, Ref{Cdouble},Cstring),tmparray,x,f,g,xl,xu,param, rw,pf,key) else ccall((:midacoJL,"./midacoJL.dll"), Void,(Ref{Cdouble},Ref{Cdouble},Ref{Cdouble},Ref{Cdouble}, Ref{Cdouble},Ref{Cdouble},Ref{Cdouble},Ref{Cdouble}, Ref{Cdouble},Cstring),tmparray,x,f,g,xl,xu,param, rw,pf,key) end end ######################################################################## ######################################################################## ########################################################################