Initialize the class. This should be the first routine called.
Note: this is a combination of the routines from the original code: oginit, ogcdel, ogcpri, ogcsca, ogcstr, ogctyp, ogderi, ogdist, ogiter, ogomet, ogplog, ogsopt, ogvsca, ogvstr, ogvtyp, ogwlog, ogwmat, ogwtab
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(optgra), | intent(out) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | Numvar |
NUMBER OF VARIABLES |
||
| integer(kind=ip), | intent(in) | :: | Numcon |
NUMBER OF CONSTRAINTS |
||
| procedure(calval_f) | :: | Calval |
FUNCTION FOR VALUES -> INPUT AND OUTPUT NOT SCALED |
|||
| procedure(calder_f) | :: | Calder |
FUNCTION FOR VALUES AND DERIVATIVES -> INPUT AND OUTPUT NOT SCALED |
|||
| real(kind=wp), | intent(in) | :: | Delcon(Numcon+1) |
CONSTRAINTS DELTAS (CONSTRAINT + MERIT CONVERGENCE THRESHOLDS) |
||
| integer(kind=ip), | intent(in) | :: | Conpri(Numcon+1) |
CONSTRAINTS PRIORITY (1:NUMCON) -> 1-N lower constraint priorities are fulfilled earlier. During the initial constraint correction phase, only constraints with a priority at most k are considered in iteration k. |
||
| real(kind=wp), | intent(in) | :: | Consca(Numcon+1) |
|
||
| character(len=name_len), | intent(in) | :: | Constr(Numcon+1) |
CONIABLES NAME STRING |
||
| integer(kind=ip), | intent(in) | :: | Conlen(Numcon+1) |
CONIABLES NAME LENGTH |
||
| integer(kind=ip), | intent(in) | :: | Contyp(Numcon+1) |
CONSTRAINTS TYPE (1:NUMCON)
MERIT TYPE (1+NUMCON)
|
||
| integer(kind=ip), | intent(in) | :: | Varder |
DERIVATIVES COMPUTATION MODE
|
||
| real(kind=wp), | intent(in) | :: | Varper(Numvar) |
VARIABLES PERTURBATION FOR DERIVATIVES -> NOT SCALED |
||
| real(kind=wp), | intent(in) | :: | Varmax |
MAXIMUM DISTANCE PER ITERATION -> SCALED |
||
| real(kind=wp), | intent(in) | :: | Varsnd |
PERTURBATION FOR 2ND ORDER DERIVATIVES -> SCALED |
||
| integer(kind=ip), | intent(in) | :: | Maxite |
maximum number of iterations |
||
| integer(kind=ip), | intent(in) | :: | Itecor |
number of constraint correction iterations in the beginning. If no feasible solution is found within that many iterations, Optgra aborts |
||
| integer(kind=ip), | intent(in) | :: | Iteopt |
some other iter input ? |
||
| integer(kind=ip), | intent(in) | :: | Itediv |
some other iter input ? |
||
| integer(kind=ip), | intent(in) | :: | Itecnv |
some other iter input ? |
||
| integer(kind=ip), | intent(in) | :: | Loglup |
LOGICAL UNIT FOR WRITING PYGMO LOG |
||
| integer(kind=ip), | intent(in) | :: | Verbos |
VERBOSITY LEVEL:
|
||
| integer(kind=ip), | intent(in) | :: | Senopt |
sensitivity optimization mode
|
||
| real(kind=wp), | intent(in) | :: | Varsca(Numvar) |
VARIABLES SCALE FACTOR |
||
| character(len=name_len), | intent(in) | :: | Varstr(Numvar) |
VARIABLES NAME STRING |
||
| integer(kind=ip), | intent(in) | :: | Varlen(Numvar) |
VARIABLES NAME LENGTH |
||
| integer(kind=ip), | intent(in) | :: | Vartyp(Numvar) |
VARIABLES TYPE
|
||
| integer(kind=ip), | intent(in) | :: | Loglun |
LOGICAL UNIT FOR WRITING LOG |
||
| integer(kind=ip), | intent(in) | :: | Loglev |
LEVEL OF LOG:
|
||
| integer(kind=ip), | intent(in) | :: | Matlev |
LEVEL OF LOG:
|
||
| integer(kind=ip), | intent(in) | :: | Tablun |
logical unit for writing table |
||
| integer(kind=ip), | intent(in) | :: | Tablev |
LEVEL OF TAB
|
||
| integer(kind=ip), | intent(in) | :: | Optmet |
OPTIMIZATION METHOD:
|
subroutine initialize(me,Numvar,Numcon,& Calval,Calder,Delcon,Conpri,Consca,Constr,Conlen,& Contyp,Varder,Varper,Varmax,Varsnd,& Maxite,Itecor,Iteopt,Itediv,Itecnv,& Loglup,Verbos,Senopt,Varsca,& Varstr,Varlen,Vartyp,Loglun,Loglev,Matlev,& Tablun,Tablev,Optmet) !! Initialize the class. This should be the first routine called. !! !! Note: this is a combination of the routines from the original code: !! oginit, ogcdel, ogcpri, ogcsca, ogcstr, ogctyp, ogderi, ogdist, !! ogiter, ogomet, ogplog, ogsopt, ogvsca, ogvstr, ogvtyp, ogwlog, !! ogwmat, ogwtab !! !!@note Could make some of these optional and keep the default values. class(optgra),intent(out) :: me integer(ip),intent(in) :: Numvar !! NUMBER OF VARIABLES integer(ip),intent(in) :: Numcon !! NUMBER OF CONSTRAINTS procedure(Calval_f) :: Calval !! FUNCTION FOR VALUES !! -> INPUT AND OUTPUT NOT SCALED procedure(Calder_f) :: Calder !! FUNCTION FOR VALUES AND DERIVATIVES !! -> INPUT AND OUTPUT NOT SCALED real(wp),intent(in) :: Delcon(Numcon+1) !! CONSTRAINTS DELTAS !! (CONSTRAINT + MERIT CONVERGENCE THRESHOLDS) integer(ip),intent(in) :: Conpri(Numcon+1) !! CONSTRAINTS PRIORITY (1:NUMCON) !! -> 1-N !! !! lower constraint priorities are fulfilled earlier. !! During the initial constraint correction phase, !! only constraints with a priority at most k are !! considered in iteration k. real(wp),intent(in) :: Consca(Numcon+1) !! * CONSTRAINTS CONVER THRESHOLD (1:NUMCON) !! * MERIT CONVER THRESHOLD (1+NUMCON) character(len=name_len),intent(in) :: Constr(Numcon+1) !! CONIABLES NAME STRING integer(ip),intent(in) :: Conlen(Numcon+1) !! CONIABLES NAME LENGTH integer(ip),intent(in) :: Contyp(Numcon+1) !! CONSTRAINTS TYPE (1:NUMCON) !! !! * 1 = GTE (positive inequality constraints) !! * -1 = LTE (inequality constraints that should be negative) !! * 0 = EQU (equality constraints) !! * -2 = DERIVED DATA (unenforced constraints) !! !! MERIT TYPE (1+NUMCON) !! !! * 1 = MAX (maximization problems) !! * -1 = MIN (minimization problems) integer(ip),intent(in) :: Varder !! DERIVATIVES COMPUTATION MODE !! !! * 1: USER DEFINED !! * 2: NUMERIC WITH DOUBLE DIFFERENCING !! * 3: NUMERIC WITH SINGLE DIFFERENCING real(wp),intent(in) :: Varper(Numvar) !! VARIABLES PERTURBATION FOR DERIVATIVES !! -> NOT SCALED real(wp),intent(in) :: Varmax !! MAXIMUM DISTANCE PER ITERATION !! -> SCALED real(wp),intent(in) :: Varsnd !! PERTURBATION FOR 2ND ORDER DERIVATIVES !! -> SCALED integer(ip),intent(in) :: Maxite !! maximum number of iterations integer(ip),intent(in) :: Itecor !! number of constraint correction iterations !! in the beginning. If no feasible solution is !! found within that many iterations, Optgra aborts integer(ip),intent(in) :: Iteopt !! some other iter input ? integer(ip),intent(in) :: Itediv !! some other iter input ? integer(ip),intent(in) :: Itecnv !! some other iter input ? integer(ip),intent(in) :: Loglup !! LOGICAL UNIT FOR WRITING PYGMO LOG integer(ip),intent(in) :: Verbos !! VERBOSITY LEVEL: !! !! * 0=NO OUTPUT !! * 1 OUTPUT EVERY ITERATION !! * 2 OUTPUT EVERY 2ND ITERATION !! * N OUTPUT EVERY NTH ITERATION integer(ip),intent(in) :: Senopt !! sensitivity optimization mode !! !! * 0: NO !! * -1: INITIALIZATION !! * +1: WITH CONSTRAINT CALCULATION !! * +2: WITH CONSTRAINT BIAS !! * +3: WITH CONSTRAINT CALC / NO OPTIM !! * +4: WITH CONSTRAINT BIAS / NO OPTIM real(wp),intent(in) :: Varsca(Numvar) !! VARIABLES SCALE FACTOR character(len=name_len),intent(in) :: Varstr(Numvar) !! VARIABLES NAME STRING integer(ip),intent(in) :: Varlen(Numvar) !! VARIABLES NAME LENGTH integer(ip),intent(in) :: Vartyp(Numvar) !! VARIABLES TYPE !! !! * 0=FREE VARIABLE !! * 1=PARAMETER FOR SENSITIVITY integer(ip),intent(in) :: Loglun !! LOGICAL UNIT FOR WRITING LOG integer(ip),intent(in) :: Loglev !! LEVEL OF LOG: !! !! * 0=NO OUTPUT !! * 1<ALL integer(ip),intent(in) :: Matlev !! LEVEL OF LOG: !! !! * 0=NO OUTPUT !! * 1<ALL integer(ip),intent(in) :: Tablun !! logical unit for writing table integer(ip),intent(in) :: Tablev !! LEVEL OF TAB !! !! * 0=NO OUTPUT !! * 1<ALL integer(ip),intent(in) :: Optmet !! OPTIMIZATION METHOD: !! !! * 3: CONJUGATE GRADIENT METHOD !! * 2: SPECTRAL CONJUGATE GRADIENT METHOD !! * 1: MODIFIED SPECTRAL CONJUGATE GRADIENT METHOD !! * 0: STEEPEST DESCENT METHOD integer(ip) :: con, var !! counter call me%destroy() ! set the functions: me%Calval => Calval me%Calder => Calder ! VARIABLES me%Numvar = Numvar allocate (me%Varval(me%Numvar)) allocate (me%Vartyp(me%Numvar)) allocate (me%Varsca(me%Numvar)) allocate (me%Varstr(me%Numvar)) allocate (me%Varlen(me%Numvar)) allocate (me%Varref(me%Numvar)) allocate (me%Vardes(me%Numvar)) allocate (me%Vargrd(me%Numvar)) allocate (me%Vardir(me%Numvar)) allocate (me%Funvar(me%Numvar)) allocate (me%Senvar(me%Numvar)) do var = 1 , me%Numvar me%Varval(var) = 0.0_wp me%Vartyp(var) = 0 me%Varsca(var) = 1.0_wp me%Varstr(var) = "" me%Varlen(var) = 0 me%Varref(var) = 0.0_wp me%Vardes(var) = 0.0_wp me%Vargrd(var) = 0.0_wp me%Vardir(var) = 0.0_wp me%Funvar(var) = 0.0_wp me%Senvar(var) = 0.0_wp end do ! CONSTRAINTS me%Numcon = Numcon allocate (me%Conval(me%Numcon+1)) allocate (me%Contyp(me%Numcon+1)) allocate (me%Conpri(me%Numcon+1)) allocate (me%Consca(me%Numcon+1)) allocate (me%Constr(me%Numcon+1)) allocate (me%Conlen(me%Numcon+1)) allocate (me%Conref(me%Numcon+1)) allocate (me%Senqua(me%Numcon+1)) allocate (me%Sencon(me%Numcon+1)) allocate (me%Sendel(me%Numcon+1)) allocate (me%Senact(me%Numcon+1)) do con = 1 , me%Numcon + 1 me%Conval(con) = 0.0_wp me%Contyp(con) = 0 me%Conpri(con) = 1 me%Consca(con) = 1.0_wp me%Constr(con) = "" me%Conlen(con) = 0 me%Conref(con) = 0.0_wp me%Senqua(con) = 0.0_wp me%Sencon(con) = 0.0_wp me%Sendel(con) = 0.0_wp me%Senact(con) = 0 end do ! CONTROL me%Optmet = 2 me%Maxite = 10 me%Corite = 10 me%Optite = 10 me%Divite = 10 me%Cnvite = 10 me%Varmax = 10.0_wp me%Varsnd = 1.0_wp ! DERIVATIVES me%Varder = 1 allocate (me%Varper(me%Numvar)) do var = 1 , me%Numvar me%Varper(var) = 1.0e-03_wp end do me%Loglun = output_unit ! LOG FILE me%Loglev = 1 me%Loglup = output_unit ! PYGMO LOG FILE me%Loglev = 0 me%Matlev = 0 ! MATLAB CONSOLE me%Tablun = output_unit ! TABLE FILE me%Tablev = 0 me%Senopt = 0 ! LINEAR OPTIMIZATION MODE ! WORKING VECTORS allocate (me%Actcon(me%Numcon+1)) allocate (me%Confix(me%Numcon)) allocate (me%Conact(me%Numcon+4)) allocate (me%Conder(me%Numcon+3,me%Numvar)) allocate (me%Conred(me%Numcon+3,me%Numvar)) allocate (me%Sender(me%Numcon+3,me%Numvar)) ! ALLOCATE (me%Conopt(me%Numcon+1)) me%Numact = 0 me%Actcon = 0 me%Conact = 0 me%Confix = 0 me%Conder = 0.0_wp me%Conred = 0.0_wp !me%Conopt = 0 ! NOTE: should the last element also be set? (not done in original) ????? do con = 1 , me%Numcon me%Sendel(con) = Delcon(con) end do do con = 1 , me%Numcon + 1 me%Conpri(con) = Conpri(con) me%Consca(con) = Consca(con) me%Constr(con) = Constr(con) me%Conlen(con) = min(Conlen(con),name_len) me%Contyp(con) = Contyp(con) end do me%Varder = Varder do var = 1 , me%Numvar me%Varper(var) = Varper(var) me%Varsca(var) = Varsca(var) me%Varstr(var) = Varstr(var) me%Varlen(var) = min(Varlen(var),name_len) me%Vartyp(var) = Vartyp(var) end do me%Varmax = Varmax me%Varsnd = Varsnd me%Maxite = Maxite me%Corite = Itecor me%Optite = Iteopt me%Divite = Itediv me%Cnvite = Itecnv if ( me%Corite>me%Maxite ) me%Corite = me%Maxite if ( me%Optite>me%Maxite ) me%Optite = me%Maxite if ( me%Divite>me%Corite ) me%Divite = me%Corite if ( me%Cnvite>me%Optite ) me%Cnvite = me%Optite me%Loglup = Loglup me%Verbos = Verbos me%Fevals = 0 ! initialize number of cost fun evaluations me%Pygfla = 0 ! pygmo output status flag: 0: continue iterating, 1: final output me%Senopt = Senopt me%Loglun = Loglun me%Loglev = Loglev me%Matlev = Matlev me%Tablun = Tablun me%Tablev = Tablev me%Optmet = Optmet end subroutine initialize