Changeset 5803


Ignore:
Timestamp:
11/13/08 22:37:07 (5 years ago)
Author:
wehart
Message:

Update to get the EAminlp building in scolib.

Location:
scolib/trunk
Files:
1 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • scolib/trunk/scolib/DomainOpsBinary.h

    r5797 r5803  
    1818 
    1919#include <acro_config.h> 
     20#include <scolib/DomainOpsBase.h> 
    2021#include <utilib/DUniform.h> 
    2122#include <utilib/_math.h> 
     
    2425#include <utilib/BasicArray.h> 
    2526#include <utilib/Uniform.h> 
    26 #include <utilib/ParameterSet.h> 
    27 #include <scolib/DomainOpsBase.h> 
    2827 
    2928#if !defined(DOXYGEN) 
     
    4241/// 
    4342template <class InfoT> 
    44 class DomainOpsBinary : public utilib::ParameterSet, public utilib::CommonIO 
     43class DomainOpsBinary : public utilib::CommonIO 
    4544{ 
    4645public: 
     
    5352 
    5453  /// 
    55   DomainOpsBinary(); 
     54  DomainOpsBinary(utilib::OptionParser& option); 
    5655 
    5756  /// 
     
    144143 
    145144template <class InfoT> 
    146 DomainOpsBinary<InfoT>::DomainOpsBinary() : 
     145DomainOpsBinary<InfoT>::DomainOpsBinary(utilib::OptionParser& option) : 
    147146  nvars(0), 
    148147  popsize(0), 
     
    151150{ 
    152151crossover_blocksize=1; 
    153 ParameterSet::create_categorized_parameter("binary_xover_blocksize", 
    154         crossover_blocksize, 
    155         "<int>","1", 
    156         "Block size used with binary two-point and uniform crossover", 
    157         "Mutation"); 
     152option.add("binary_xover_blocksize", crossover_blocksize, 
     153        "Block size used with binary two-point and uniform crossover"); 
     154option.categorize("binary_xover_blocksize",     "Mutation"); 
    158155 
    159156crossover_str="twopoint"; 
    160 ParameterSet::create_categorized_parameter("binary_xover_type", 
    161         crossover_str, 
    162         "<string>","twopoint", 
    163         "Crossover type\n\ 
    164 \t  twopoint      - standard two-point xover\n\ 
    165 \t  uniform       - standard uniform xover", 
    166         "Crossover"); 
     157option.add("binary_xover_type", crossover_str, 
     158"Crossover type\n\ 
     159    twopoint      - standard two-point xover\n\ 
     160    uniform       - standard uniform xover"); 
     161option.categorize("binary_xover_type", "Crossover"); 
    167162 
    168163mutation_xchg_num=1; 
    169 ParameterSet::create_categorized_parameter("binary_mutation_xchg", 
    170         mutation_xchg_num, 
    171         "<int>","1", 
    172         "Mutation exchange number", 
    173         "Mutation"); 
     164option.add("binary_mutation_xchg", mutation_xchg_num, 
     165        "Mutation exchange number"); 
     166option.categorize("binary_mutation_xchg", "Mutation"); 
    174167 
    175168mutation_str="standard"; 
    176 ParameterSet::create_categorized_parameter("binary_mutation_type", 
    177         mutation_str, 
    178         "<string>","standard", 
    179         "Mutation type\n\ 
    180 \t  standard - simple bit flips\n\ 
    181 \t  exchange - keep a fixed number of bits on", 
    182         "Mutation"); 
     169option.add("binary_mutation_type", mutation_str, 
     170"Mutation type\n\ 
     171    standard - simple bit flips\n\ 
     172    exchange - keep a fixed number of bits on"); 
     173option.categorize("binary_mutation_type", "Mutation"); 
    183174 
    184175mutation_allele_rate=-1.0; 
    185 ParameterSet::create_categorized_parameter("binary_mutation_allele_rate", 
    186         mutation_allele_rate, 
    187         "<double>","-1.0", 
    188         "The probability that any given bit of an individual is mutated given\n\tthat the individual is mutated", 
    189         "Mutation"); 
     176option.add("binary_mutation_allele_rate", mutation_allele_rate, 
     177        "The probability that any given bit of an individual is mutated given that the individual is mutated"); 
     178option.categorize("binary_mutation_allele_rate", "Mutation"); 
    190179} 
    191180 
  • scolib/trunk/scolib/DomainOpsIntArray.h

    r5797 r5803  
    1818 
    1919#include <acro_config.h> 
     20#include <scolib/DomainOpsArray.h> 
     21#include <colin/BoundTypeArray.h> 
    2022#include <utilib/_math.h> 
    2123#include <utilib/Uniform.h> 
    22 #include <colin/BoundTypeArray.h> 
    23 #include <scolib/DomainOpsArray.h> 
    2424 
    2525#define INT_ARRAY_MUTATION_UNIFORM  1 
     
    2828namespace scolib { 
    2929 
    30 using utilib::ParameterSet; 
    31  
    3230template <class InfoT> 
    3331class DomainOpsIntArray : public DomainOpsArray<int, InfoT> 
     
    4240 
    4341  /// 
    44   DomainOpsIntArray(); 
     42  DomainOpsIntArray(utilib::OptionParser& option); 
    4543 
    4644  /// 
     
    105103 
    106104template <class InfoT> 
    107 DomainOpsIntArray<InfoT>::DomainOpsIntArray() 
     105DomainOpsIntArray<InfoT>::DomainOpsIntArray(utilib::OptionParser& option) 
    108106{ 
    109107this->crossover_blocksize=1; 
    110 ParameterSet::create_categorized_parameter("intarray_xover_blocksize", 
    111         this->crossover_blocksize, 
    112         "<int>","1", 
    113         "Block size used with array-based two-point and uniform crossover", 
    114         "Crossover"); 
     108option.add("intarray_xover_blocksize", this->crossover_blocksize, 
     109        "Block size used with array-based two-point and uniform crossover"); 
     110option.categorize("intarray_xover_blocksize","Crossover"); 
    115111 
    116112this->crossover_str="twopoint"; 
    117 ParameterSet::create_categorized_parameter("intarray_xover_type", 
    118         this->crossover_str, 
    119         "<string>","twopoint", 
    120         "Crossover type\n\ 
    121 \t  onepoint      - standard one-point mutation\n\ 
    122 \t  twopoint      - standard two-point mutation\n\ 
    123 \t  uniform       - standard uniform mutation", 
    124         "Crossover"); 
     113option.add("intarray_xover_type", this->crossover_str, 
     114"Crossover type\n\ 
     115    onepoint      - standard one-point mutation\n\ 
     116    twopoint      - standard two-point mutation\n\ 
     117    uniform       - standard uniform mutation"); 
     118option.categorize("intarray_xover_type","Crossover"); 
    125119 
    126120this->mutation_str = "uniform"; 
    127 ParameterSet::create_categorized_parameter("intarray_mutation_type", 
    128         this->mutation_str, 
    129         "<string>","uniform", 
    130         "Integer mutation type\n\ 
    131 \t  uniform  - replace the value with a uniformly random variable\n\ 
    132 \t  interval - replace the value with a uniform value in a local interval", 
    133         "Mutation"); 
     121option.add("intarray_mutation_type", this->mutation_str, 
     122"Integer mutation type\n\ 
     123    uniform  - replace the value with a uniformly random variable\n\ 
     124    interval - replace the value with a uniform value in a local interval"); 
     125option.categorize("intarray_mutation_type","Mutation"); 
    134126 
    135127this->mutation_range=1; 
    136 ParameterSet::create_categorized_parameter("intarray_mutation_range", 
    137         this->mutation_range, 
    138         "<int>","1", 
    139         "Range of mutation used for 'interval' mutation", 
    140         "Mutation"); 
     128option.add("intarray_mutation_range", this->mutation_range, 
     129        "Range of mutation used for 'interval' mutation"); 
     130option.categorize("intarray_mutation_range","Mutation"); 
    141131 
    142132this->mutate_independently=false; 
    143 ParameterSet::create_categorized_parameter("intarray_mutate_independently", 
    144         this->mutate_independently, 
    145         "<bool>","false", 
    146         "If true, then only mutate a single dimension.  Note that if this\n\ 
    147 \tvalue is true, then a single dimension is always mutated, so the\n\ 
    148 \tmutation allele rate is ignored.", 
    149         "Mutation"); 
     133option.add("intarray_mutate_independently", this->mutate_independently, 
     134        "If true, then only mutate a single dimension.  Note that if this value is true, then a single dimension is always mutated, so the mutation allele rate is ignored."); 
     135option.categorize("intarray_mutate_independently","Mutation"); 
    150136 
    151137this->mutation_allele_rate=1.0; 
    152 ParameterSet::create_categorized_parameter("intarray_mutation_allele_rate", 
    153         this->mutation_allele_rate, 
    154         "<double>","1.0", 
    155         "The probability that any given dimension of the intarray is mutated\n\tgiven that the individual is mutated", 
    156         "Mutation"); 
     138option.add("intarray_mutation_allele_rate", this->mutation_allele_rate, 
     139        "The probability that any given dimension of the intarray is mutated given that the individual is mutated"); 
     140option.categorize("intarray_mutation_allele_rate","Mutation"); 
    157141} 
    158142 
  • scolib/trunk/scolib/DomainOpsMixedInteger.h

    r5797 r5803  
    4040 
    4141  /// 
    42   DomainOpsMixedInteger(); 
     42  DomainOpsMixedInteger(utilib::OptionParser& option); 
    4343 
    4444  /// 
     
    214214 
    215215template <class InfoT> 
    216 DomainOpsMixedInteger<InfoT>::DomainOpsMixedInteger() : 
     216DomainOpsMixedInteger<InfoT>::DomainOpsMixedInteger(utilib::OptionParser& option) : 
     217  binary_ops(option), 
     218  intarray_ops(option), 
     219  realarray_ops(option), 
    217220  mutate_independently(false) 
    218221{ 
    219 ParameterSet::create_categorized_parameter("mint_mutate_independently", 
    220         mutate_independently, 
    221         "<bool>","false", 
    222         "If true, then independently mutate binary, integer and real arrays", 
    223         "Mutation"); 
    224  
    225 augment_parameters(binary_ops); 
    226 augment_parameters(intarray_ops); 
    227 augment_parameters(realarray_ops); 
     222option.add("mint_mutate_independently", mutate_independently, 
     223        "If true, then independently mutate binary, integer and real arrays"); 
     224option.categorize("mint_mutate_independently", "Mutation"); 
    228225} 
    229226 
  • scolib/trunk/scolib/DomainOpsRealArray.h

    r5797 r5803  
    1818 
    1919#include <acro_config.h> 
     20#include <scolib/DomainOpsArray.h> 
     21#include <colin/BoundTypeArray.h> 
     22#include <colin/real.h> 
    2023#include <utilib/Normal.h> 
    2124#include <utilib/Cauchy.h> 
    22 #include <colin/real.h> 
    23 #include <colin/BoundTypeArray.h> 
    24 #include <scolib/DomainOpsArray.h> 
    2525 
    2626#define REAL_ARRAY_MUTATION_UNIFORM  1 
     
    6262 
    6363  /// 
    64   DomainOpsRealArray(); 
     64  DomainOpsRealArray(utilib::OptionParser& option); 
    6565 
    6666  /// 
     
    7070  void set_rng(utilib::AnyRNG& rng_) 
    7171        { 
    72         DomainOpsArray<double,InfoT>::set_rng(rng_); 
    73         cauchy_rnd.generator(&rng_); 
    74         normal_rnd.generator(&rng_); 
    75         } 
     72        DomainOpsArray<double,InfoT>::set_rng(rng_); 
     73        cauchy_rnd.generator(&rng_); 
     74        normal_rnd.generator(&rng_); 
     75        } 
    7676 
    7777  /// 
    7878  template <class ProblemT> 
    7979  void initialize(ProblemT& problem, unsigned int popsize_, double xover_rate, double m_rate) 
    80         { 
    81         DomainOpsArray<double,InfoT>::initialize( problem->num_real_vars(), 
    82                                                         popsize_, xover_rate, m_rate); 
    83         if ((problem->num_real_vars() > 0) && (problem->enforcing_domain_bounds())) { 
    84            problem->get_real_bounds(lower,upper); 
    85            range.resize(this->nvars); 
    86            lbound_type.resize(this->nvars); 
    87            ubound_type.resize(this->nvars); 
    88            for (size_type i=0; i<this->nvars; i++) {  
    89              lbound_type[i] = problem->real_lower_bound_type(i); 
    90              ubound_type[i] = problem->real_upper_bound_type(i); 
    91              range[i] = upper[i] - lower[i]; 
     80        { 
     81        DomainOpsArray<double,InfoT>::initialize( problem->num_real_vars(), 
     82                                                        popsize_, xover_rate, m_rate); 
     83        if ((problem->num_real_vars() > 0) && (problem->enforcing_domain_bounds())) { 
     84           problem->get_real_bounds(lower,upper); 
     85           range.resize(this->nvars); 
     86           lbound_type.resize(this->nvars); 
     87           ubound_type.resize(this->nvars); 
     88           for (size_type i=0; i<this->nvars; i++) {  
     89             lbound_type[i] = problem->real_lower_bound_type(i); 
     90             ubound_type[i] = problem->real_upper_bound_type(i); 
     91             range[i] = upper[i] - lower[i]; 
    9292             } 
    93            } 
    94         tau = 1.0/std::sqrt(2*std::sqrt( static_cast<double>(this->nvars) )); 
    95         taudash = 1.0/std::sqrt( 2.0*(this->nvars) ); 
     93           } 
     94        tau = 1.0/std::sqrt(2*std::sqrt( static_cast<double>(this->nvars) )); 
     95        taudash = 1.0/std::sqrt( 2.0*(this->nvars) ); 
    9696        mutation_direction.resize(this->nvars); 
    97         } 
     97        } 
    9898 
    9999  /// 
    100100  void initialize_point(utilib::BasicArray<double>& point, info_t& info) 
    101         { 
    102         point.resize(this->nvars); 
    103         info.scale.resize(this->nvars); 
    104         if (auto_rescale) 
    105            info.scale << range; 
    106         else 
    107            info.scale << 1.0; 
    108         } 
     101        { 
     102        point.resize(this->nvars); 
     103        info.scale.resize(this->nvars); 
     104        if (auto_rescale) 
     105              info.scale << range; 
     106        else 
     107              info.scale << 1.0; 
     108        } 
    109109  
    110110  /// 
     
    117117  /// 
    118118  bool apply_mutation(point_t& point, info_t& info, int parent_ndx) 
    119         { 
    120         N = normal_rnd(); 
    121         return DomainOpsArray<double,InfoT>::apply_mutation(point,info, 
    122                                                 parent_ndx); 
    123         } 
     119        { 
     120        N = normal_rnd(); 
     121        return DomainOpsArray<double,InfoT>::apply_mutation(point,info, 
     122                                                parent_ndx); 
     123        } 
    124124 
    125125  /// 
     
    185185 
    186186template <class InfoT> 
    187 DomainOpsRealArray<InfoT>::DomainOpsRealArray() 
     187DomainOpsRealArray<InfoT>::DomainOpsRealArray(utilib::OptionParser& option) 
    188188{ 
    189189this->crossover_blocksize=1; 
    190 ParameterSet::create_categorized_parameter("realarray_xover_blocksize", 
    191         this->crossover_blocksize, 
    192         "<int>","1", 
    193         "Block size used with array-based two-point and uniform crossover", 
    194         "Crossover"); 
     190option.add("realarray_xover_blocksize", this->crossover_blocksize, 
     191        "Block size used with array-based two-point and uniform crossover"); 
     192option.categorize("realarray_xover_blocksize","Crossover"); 
    195193 
    196194this->crossover_alpha=0.5; 
    197 ParameterSet::create_categorized_parameter("realarray_xover_alpha", 
    198         this->crossover_alpha, 
    199         "<double>","0.5", 
    200         "Extent of blend crossover beyond the line connecting the two points", 
    201         "Crossover"); 
     195option.add("realarray_xover_alpha", this->crossover_alpha, 
     196        "Extent of blend crossover beyond the line connecting the two points"); 
     197option.categorize("realarray_xover_alpha","Crossover"); 
    202198 
    203199this->crossover_str="twopoint"; 
    204 ParameterSet::create_categorized_parameter("realarray_xover_type", 
    205         this->crossover_str, 
    206         "<string>","twopoint", 
    207         "Crossover type\n\ 
    208 \t  blend         - an alpha-blend mutaiton\n\ 
    209 \t  twopoint      - standard two-point mutation\n\ 
    210 \t  uniform       - standard uniform mutation", 
    211         "Crossover"); 
    212  
     200option.add("realarray_xover_type", this->crossover_str, 
     201"Crossover type\n\ 
     202    blend         - an alpha-blend mutaiton\n\ 
     203    twopoint      - standard two-point mutation\n\ 
     204    uniform       - standard uniform mutation"); 
     205option.categorize("realarray_xover_type", "Crossover"); 
    213206 
    214207mutation_str = "step"; 
    215 ParameterSet::create_categorized_parameter("realarray_mutation_type", 
    216         mutation_str, 
    217         "<string>","step", 
    218         "Mutation type\n\ 
    219 \t  uniform  - replace the value with a uniformly random value\n\ 
    220 \t  normal   - replace the value with a normal random variable\n\ 
    221 \t  cauchy   - replace the value with a cauchy random variable\n\ 
    222 \t  step     - replace the value with a simple coordinate step\n\ 
    223 \t  interval - replace the value with a uniform value in a local interval", 
    224         "Mutation"); 
     208option.add("realarray_mutation_type", mutation_str, 
     209"Mutation type\n\ 
     210uniform  - replace the value with a uniformly random value\n\ 
     211normal   - replace the value with a normal random variable\n\ 
     212cauchy   - replace the value with a cauchy random variable\n\ 
     213step     - replace the value with a simple coordinate step\n\ 
     214interval - replace the value with a uniform value in a local interval"); 
     215option.categorize("realarray_mutation_type","Mutation"); 
    225216 
    226217auto_rescale=true; 
    227 ParameterSet::create_categorized_parameter("realarray_autorescale", 
    228         auto_rescale, 
    229         "<bool>","true", 
    230         "Automatically rescale mutation steps as a fraction of the parameter range", 
    231         "Mutation"); 
     218option.add("realarray_autorescale", auto_rescale, 
     219        "Automatically rescale mutation steps as a fraction of the parameter range"); 
     220option.categorize("realarray_autorescale","Mutation"); 
    232221 
    233222mutation_scale=0.1; 
    234 ParameterSet::create_categorized_parameter("realarray_mutation_scale", 
    235         mutation_scale, 
    236         "<int>","0.1", 
    237         "Global scale multiplied types search scale", 
    238         "Mutation"); 
     223option.add("realarray_mutation_scale", mutation_scale, 
     224        "Global scale multiplied types search scale"); 
     225option.categorize("realarray_mutation_scale","Mutation"); 
    239226 
    240227mutation_self_adaptation=true; 
    241 ParameterSet::create_categorized_parameter("realarray_mutation_selfadaptation", 
    242         mutation_self_adaptation, "<bool>", "true", 
    243         "If true, then the step scale used for mutation is self-adapted.", 
    244         "Mutation"); 
     228option.add("realarray_mutation_selfadaptation", mutation_self_adaptation,  
     229        "If true, then the step scale used for mutation is self-adapted."); 
     230option.categorize("realarray_mutation_selfadaptation","Mutation"); 
    245231 
    246232this->min_self_adaptive_scale_factor=1e-6; 
    247 ParameterSet::create_categorized_parameter("min_self_adaptive_scale_factor", 
    248         this->min_self_adaptive_scale_factor, 
    249         "<double>","1e-6", 
    250         "A minimum threshold for the self_adaptive scale factor.", 
    251         "Mutation"); 
    252  
     233option.add("min_self_adaptive_scale_factor", 
     234        this->min_self_adaptive_scale_factor, 
     235        "A minimum threshold for the self_adaptive scale factor."); 
     236option.categorize("min_self_adaptive_scale_factor","Mutation"); 
    253237 
    254238this->mutate_independently=false; 
    255 ParameterSet::create_categorized_parameter("realarray_mutate_independently", 
    256         this->mutate_independently, 
    257         "<bool>","false", 
    258         "If true, then only mutate a single dimension.  Note that if this\n\ 
    259 \tvalue is true, then a single dimension is always mutated, so the\n\ 
    260 \tmutation allele rate is ignored.", 
    261         "Mutation"); 
     239option.add("realarray_mutate_independently", this->mutate_independently, 
     240        "If true, then only mutate a single dimension.  Note that if this value is true, then a single dimension is always mutated, so the mutation allele rate is ignored."); 
     241option.categorize("realarray_mutate_independently","Mutation"); 
    262242 
    263243this->mutation_allele_rate=1.0; 
    264 ParameterSet::create_categorized_parameter("realarray_mutation_allele_rate", 
    265         this->mutation_allele_rate, 
    266         "<double>","1.0", 
    267         "The probability that any given dimension of the realarray is mutated\n\tgiven that the individual is mutated", 
    268         "Mutation"); 
    269  
     244option.add("realarray_mutation_allele_rate", 
     245        this->mutation_allele_rate, 
     246        "The probability that any given dimension of the realarray is mutated given that the individual is mutated"); 
     247option.categorize("realarray_mutation_allele_rate","Mutation"); 
    270248} 
    271249 
     
    278256 
    279257mutation_allele_rate = (mutation_allele_rate < 0.0 ?  
    280                                 std::sqrt(M_E/(double)this->nvars)/(double)popsize : 
    281                                 mutation_allele_rate); 
     258                                std::sqrt(M_E/(double)this->nvars)/(double)popsize : 
     259                                mutation_allele_rate); 
    282260if ((mutation_str == "uniform") || (mutation_str == "offset_uniform")) 
    283261   mutation_type = REAL_ARRAY_MUTATION_UNIFORM; 
     
    354332switch (mutation_type) { 
    355333  case REAL_ARRAY_MUTATION_INTERVAL: 
    356                 tmp = 2.0*this->rnd()-1.0; 
    357                 break; 
     334                tmp = 2.0*this->rnd()-1.0; 
     335                break; 
    358336 
    359337  case REAL_ARRAY_MUTATION_NORMAL: 
    360                 tmp = normal_rnd(); 
    361                 break; 
     338                tmp = normal_rnd(); 
     339                break; 
    362340 
    363341  case REAL_ARRAY_MUTATION_CAUCHY: 
    364                 tmp = cauchy_rnd(); 
    365                 break; 
     342                tmp = cauchy_rnd(); 
     343                break; 
    366344 
    367345  case REAL_ARRAY_MUTATION_STEP: 
    368                 tmp = ((bias < 0.0) || (this->rnd() < 0.5) ? -1.0 : 1.0); 
    369                 break; 
     346                tmp = ((bias < 0.0) || (this->rnd() < 0.5) ? -1.0 : 1.0); 
     347                break; 
    370348 
    371349  default: 
    372                 break; 
     350                break; 
    373351  }; 
    374352if (bias != 0.0) 
     
    429407        for (unsigned int i=0; i<this->nvars; i++) { 
    430408          if ((lower[i] != upper[i]) && (parent1[i] != parent2[i])) { 
    431              double alpha1_value = alpha1 * parent1[i] + 
    432                                       (1.0 - alpha1) * parent2[i]; 
     409             double alpha1_value = alpha1 * parent1[i] + 
     410                                           (1.0 - alpha1) * parent2[i]; 
    433411             if (alpha1_value < lower[i]) 
    434412                   alpha1 = (lower[i] - parent2[i])/ 
    435                                         (parent1[i]-parent2[i]); 
     413                                        (parent1[i]-parent2[i]); 
    436414             else if (alpha1_value > upper[i]) 
    437415                   alpha1 = (upper[i] - parent2[i])/ 
    438                                         (parent1[i]-parent2[i]); 
     416                                        (parent1[i]-parent2[i]); 
    439417 
    440418             double alpha2_value = alpha2 * parent1[i] +  
    441                                       (1.0 - alpha2) * parent2[i]; 
    442              if (alpha2_value > upper[i]) 
     419                                      (1.0 - alpha2) * parent2[i]; 
     420             if (alpha2_value > upper[i]) 
    443421                   alpha2 = (upper[i] - parent2[i])/ 
    444                                         (parent1[i]-parent2[i]); 
     422                                        (parent1[i]-parent2[i]); 
    445423             if (alpha2_value < lower[i]) 
    446424                   alpha2 = (lower[i] - parent2[i])/ 
    447                                         (parent1[i]-parent2[i]); 
     425                                        (parent1[i]-parent2[i]); 
    448426             } 
    449427           } 
     
    490468                 ); 
    491469        } 
    492         break; 
     470        break; 
    493471 
    494472  default: 
    495         return base_t::apply_xover(parent1,info1,parent2,info2,child,info_c); 
     473        return base_t::apply_xover(parent1,info1,parent2,info2,child,info_c); 
    496474  }; 
    497475 
  • scolib/trunk/scolib/EAbase.h

    r5797 r5803  
    432432   } 
    433433if (ls_freq > 0.0) { 
    434    this->set_parameter("realarray_mutation_selfadaptation",false); 
     434   this->option.set_parameter("realarray_mutation_selfadaptation",false); 
    435435   lsMask.resize(popsize()); 
    436436   lsMask.reset(); 
     
    925925OUTPUTPR(10, ucout << "[Starting pt: " << child << "]\n"); 
    926926Eval(child,true); 
    927 (this->sub_solver[0].first)->set_initial_point(child.pt.point); 
     927(this->sub_solver[0].first)->add_initial_point(child.pt.point); 
    928928 
    929929int debug_neval = -1; 
     
    938938// 
    939939init_ls(child); 
    940 (this->sub_solver[0].first)->minimize(); 
     940(this->sub_solver[0].first)->optimize(); 
    941941fini_ls(child); 
    942942 
    943943 
     944#if 0 
     945  ERROR - this assumes that the final point is being returned with a 
     946  function value! 
    944947OUTPUTPR(1000, 
    945948         ucout << "[LS_Fini_Val:\t" 
     
    949952               << std::endl; 
    950953         ); 
     954#endif 
    951955// 
    952956// If we are performing offline local search, then we don't actually 
     
    960964child.ls_flag = true; 
    961965child.eval_flag=false; 
     966#if 0 
     967  WEH - ERROR this assumes that the final point has a value! 
    962968typename EAbase<PointT,DomainT,ProblemT>::response_t& lresponse = (this->sub_solver[0].first)->opt_response.response;  
    963969child.update((this->sub_solver[0].first)->opt_response, Lamarck_flag); 
     970#endif 
     971 
    964972#if 0 
    965973// 
  • scolib/trunk/scolib/EAgeneric.h

    r5797 r5803  
    3131 
    3232  /// 
    33   const char* get_name() { return "EAgeneric"; } 
     33  const char* get_name() const { return "EAgeneric"; } 
    3434}; 
    3535 
     
    3838/// 
    3939template <class DomainT, class ProblemT, class InfoT, class OpClassT> 
    40 class EAgeneric : public PEAbase<EApoint<DomainT,InfoT>, DomainT, ProblemT > 
     40class EAgeneric : public PEAbase<EApoint<DomainT,InfoT>, DomainT, ProblemT >, public EAgeneric_name<DomainT,ProblemT,InfoT,OpClassT> 
    4141{ 
    4242  #if !defined(DOXYGEN) 
     
    5757  /// 
    5858  EAgeneric() 
    59         { 
    60         search_ops = new OpClassT; 
     59    : PEAbase<EApoint<DomainT,InfoT>, DomainT, ProblemT >() 
     60        { 
     61        search_ops = new OpClassT(this->option); 
    6162        #if 0 
    6263        ParameterSet::create_parameter("distinct_initial_population", 
     
    6566          "If true, then the initial population is composed of distinct points"); 
    6667        #endif 
    67         augment_parameters(*search_ops); 
     68        //augment_parameters(*search_ops); 
    6869        } 
    6970 
  • scolib/trunk/scolib/EAminlp.h

    r5797 r5803  
    3030        scolib::DomainInfoMixedInteger, 
    3131        scolib::DomainOpsMixedInteger<scolib::DomainInfoMixedInteger> > 
    32 { protected: const char* get_name() { return "EAminlp"; } }; 
     32{ protected: const char* get_name() const { return "EAminlp"; } }; 
    3333 
    3434 
  • scolib/trunk/scolib/Makefile.am

    r5797 r5803  
    4242  $(FULLPATH_SRC)/Grasp.h\ 
    4343  $(FULLPATH_SRC)/MultiStart.h\ 
    44   $(FULLPATH_SRC)/Factory.h\ 
     44  $(FULLPATH_SRC)/SCORegistrations.h\ 
    4545  $(FULLPATH_SRC)/PLGO.h\ 
    4646  $(FULLPATH_SRC)/PIDOMS.h 
  • scolib/trunk/scolib/PEAbase.h

    r5797 r5803  
    5151  //@{ 
    5252  /// 
    53   PEAbase(utilib::OptionParser& option); 
     53  PEAbase(); 
    5454 
    5555  /// 
     
    143143  
    144144template <class PointT, class DomainT, class ProblemT> 
    145 PEAbase<PointT,DomainT,ProblemT>::PEAbase(utilib::OptionParser& option) 
     145PEAbase<PointT,DomainT,ProblemT>::PEAbase() 
     146: selection_obj(this->option) 
    146147{ 
    147148popsize_=0; 
     
    149150 
    150151replacement_str = "elitist"; 
    151 option.add("replacement_method", replacement_str, 
     152this->option.add("replacement_method", replacement_str, 
    152153"Controls how points from the previous population are replaced by the newly generated points.  If more than (population_size-keep_num) new points are generated, then the best of these points are used for replacement.\n\ 
    153154    random      - new points replace randomly selection points in the previous population\n\ 
     
    155156    chc         - the keep_num best individuals from BOTH the previous population and the new points are kept, and the remaining individuals are randomly selected from both sets of points to fill the (popsize-keep_num) remaining slots\n\ 
    156157    exponential - new points replace the worst points in the previous population with a probability that decreases exponentially as their rank increases"); 
    157 option.categorize("replacement_method", "Selection/Replacement"); 
    158 option.alias("replacement_method","replacement_type"); 
     158this->option.categorize("replacement_method", "Selection/Replacement"); 
     159this->option.alias("replacement_method","replacement_type"); 
    159160 
    160161num_trial_points=0; 
    161 option.add("num_trial_points",num_trial_points, 
     162this->option.add("num_trial_points",num_trial_points, 
    162163        "The number of new trial points created in each iteration"); 
    163 option.categorize("num_trial_points", "Selection/Replacement"); 
     164this->option.categorize("num_trial_points", "Selection/Replacement"); 
    164165 
    165166this->keep_num=1; 
    166 option.add("keep_num",keep_num, 
     167this->option.add("keep_num",keep_num, 
    167168        "The number of best points kept in chc and elitist replacement"); 
    168 option.categorize("keep_num", "Selection/Replacement"); 
     169this->option.categorize("keep_num", "Selection/Replacement"); 
    169170 
    170171exp_replacement_factor=0.5; 
    171 option.add("exponential_replacement_factor", exp_replacement_factor, 
     172this->option.add("exponential_replacement_factor", exp_replacement_factor, 
    172173"The factor used to define the exponential decay of probabilities in exponential replacement.  Factors near 1.0 provide a uniform selection probability."); 
    173 option.categorize("exponential_replacement_factor", "Selection/Replacement"); 
    174  
    175 this->augment_parameters(selection_obj); 
     174this->option.categorize("exponential_replacement_factor", "Selection/Replacement"); 
    176175} 
    177176 
  • scolib/trunk/scolib/panmictic_selection.h

    r5797 r5803  
    3131 
    3232  /// Constructor. 
    33   panmictic_selection() 
    34          : selection<ObjectT,AccessorT,CompareT>() {set_window(10);} 
     33  panmictic_selection(utilib::OptionParser& option) 
     34         : selection<ObjectT,AccessorT,CompareT>(option) {set_window(10);} 
    3535 
    3636  /// Reset this object. 
  • scolib/trunk/src/Makefile.am

    r5797 r5803  
    4040lib/DynamicGSS.cpp\ 
    4141lib/MultiStatePS.cpp\ 
    42 lib/factory.cpp\ 
     42lib/SCORegistrations.cpp\ 
    4343lib/PLGO.cpp 
    4444 
  • scolib/trunk/src/exec/scolib.cpp

    r5797 r5803  
    1313 
    1414#if 1 
    15  
     15#include <scolib/SCORegistrations.h> 
    1616#include <colin/ColinDriver.h> 
    1717 
    1818int main(int argc, char* argv[]) 
    1919{ 
     20static_cast<void>(scolib::StaticInitializers::static_scolib_registrations); 
    2021return colin::colin_driver(argc,argv,"scolib"); 
    2122} 
  • scolib/trunk/src/lib/Direct.cpp

    r5797 r5803  
    18821882 
    18831883 
    1884 namespace StaticInitializers { 
    1885  
    1886 namespace { 
    1887  
    1888 bool RegisterDirect() 
    1889 { 
    1890    colin::SolverMngr().declare_solver_type<DIRECT> 
    1891       ("scolib:DIRECT", "The DIRECT global optimizer"); 
    1892  
    1893    colin::SolverMngr().declare_solver_type<DIRECT> 
    1894       ("scolib:direct", "An alias to scolib:DIRECT"); 
    1895  
    1896    return true; 
    1897 } 
    1898  
    1899 } // namespace scolib::StaticInitializers::(local) 
    1900  
    1901 extern const volatile bool direct = RegisterDirect(); 
    1902  
    1903 } // namespace scolib::StaticInitializers 
     1884REGISTER_COLIN_SOLVER_WITH_ALIAS(DIRECT,"sco:DIRECT","sco:direct", "The SCO DIRECT optimizer") 
    19041885 
    19051886} // namespace scolib 
    19061887 
    1907 /* 
    1908 FACTORY_NAMED_REGISTER(direct, "scolib:direct", colin::OptSolverHandle*, 
    1909                 return new colin::ConcreteOptSolverHandle<scolib::DIRECT>;, 
    1910                 "An alias to DIRECT") 
    1911 FACTORY_NAMED_REGISTER(DIRECT, "scolib:DIRECT", colin::OptSolverHandle*, 
    1912                 return new colin::ConcreteOptSolverHandle<scolib::DIRECT>;, 
    1913                 "The DIRECT global optimizer") 
    1914 */ 
    1915  
    1916  
  • scolib/trunk/src/lib/DockingPS.cpp

    r5797 r5803  
    492492 
    493493 
    494 namespace StaticInitializers { 
    495  
    496 namespace { 
    497  
    498 bool RegisterDockingPS() 
    499 { 
    500    colin::SolverMngr().declare_solver_type<DockingPS> 
    501       ("scolib:DockingPS",  
    502        "A derivative free pattern search for flexible docking"); 
    503  
    504    colin::SolverMngr().declare_solver_type<DockingPS> 
    505       ("scolib:dockingps", "An alias to scolib:DockingPS"); 
    506  
    507    return true; 
    508 } 
    509  
    510 } // namespace scolib::StaticInitializers::(local) 
    511  
    512 extern const volatile bool docking_ps = RegisterDockingPS(); 
    513  
    514 } // namespace scolib::StaticInitializers 
     494REGISTER_COLIN_SOLVER_WITH_ALIAS(DockingPS,"sco:DockingPS","sco:dockingps", "The SCO DockingPS optimizer") 
    515495 
    516496} // namespace scolib 
    517 /* 
    518 FACTORY_NAMED_REGISTER(DockingPS, "scolib:DockingPS", colin::OptSolverHandle*, 
    519                 return new colin::ConcreteOptSolverHandle<scolib::DockingPS>;, 
    520                 "A derivative free pattern search for flexible docking") 
    521 FACTORY_NAMED_REGISTER(dockingps, "scolib:dockingps", colin::OptSolverHandle*, 
    522                 return new colin::ConcreteOptSolverHandle<scolib::DockingPS>;, 
    523                 "An alias to DockingPS") 
    524 */ 
  • scolib/trunk/src/lib/MultiStatePS.cpp

    r5797 r5803  
    12451245 
    12461246 
    1247 namespace StaticInitializers { 
    1248  
    1249 namespace { 
    1250  
    1251 bool RegisterMultiStatePS() 
    1252 { 
    1253    colin::SolverMngr().declare_solver_type<MultiStatePS> 
    1254       ("scolib:MultiState",  
    1255        "The MultiState Pattern Search optimizer"); 
    1256  
    1257    colin::SolverMngr().declare_solver_type<MultiStatePS> 
    1258       ("scolib:msps", "An alias to scolib:MultiState"); 
    1259  
    1260    return true; 
    1261 } 
    1262  
    1263 } // namespace scolib::StaticInitializers::(local) 
    1264  
    1265 extern const volatile bool multistate_ps = RegisterMultiStatePS(); 
    1266  
    1267 } // namespace scolib::StaticInitializers 
     1247REGISTER_COLIN_SOLVER_WITH_ALIAS(MultiStatePS,"sco:MultiStatePS","sco:msps", "The SCO       DIRECT optimizer") 
    12681248 
    12691249} // namespace scolib 
    1270 /* 
    1271 FACTORY_NAMED_REGISTER(msps, "scolib:msps", colin::OptSolverHandle*, return new  
    1272                  colin::ConcreteOptSolverHandle<scolib::MultiStatePS>;, 
    1273                 "The MultiState Pattern Search optimizer") 
    1274 FACTORY_NAMED_REGISTER(MultiState, "scolib:MultiState", colin::OptSolverHandle*, return new  
    1275                  colin::ConcreteOptSolverHandle<scolib::MultiStatePS>;, 
    1276                 "The MultiState Pattern Search optimizer") 
    1277 */ 
  • scolib/trunk/src/lib/PLGO.cpp

    r5797 r5803  
    115115 
    116116 
    117 namespace StaticInitializers { 
    118  
    119 namespace { 
    120  
    121 bool RegisterPLGO() 
    122 { 
    123    colin::SolverMngr().declare_solver_type<PLGO> 
    124       ("scolib:plipshitzian", "A parallel Lipshitzian global optimizer"); 
    125  
    126    colin::SolverMngr().declare_solver_type<PLGO> 
    127       ("scolib:plgo", "An alias to coling:plipshitzian"); 
    128  
    129    return true; 
    130 } 
    131  
    132 } // namespace scolib::StaticInitializers::(local) 
    133  
    134 extern const volatile bool plgo = RegisterPLGO(); 
    135  
    136 } // namespace scolib::StaticInitializers 
     117REGISTER_COLIN_SOLVER_WITH_ALIAS(PLGO,"sco:PLGO","sco:plgo", "The SCO PLGO optimizer") 
    137118 
    138119} // namespace scolib 
    139  
    140 /* 
    141 FACTORY_NAMED_REGISTER(plgo, "scolib:plgo", colin::OptSolverHandle*, 
    142                 return new colin::ConcreteOptSolverHandle<scolib::PLGO>;, 
    143                 "An alias to PLGO") 
    144 FACTORY_NAMED_REGISTER(plipshitzian, "scolib:plipshitzian", colin::OptSolverHandle*, 
    145                 return new colin::ConcreteOptSolverHandle<scolib::PLGO>;, 
    146                 "A parallel Lipshitzian global optimizer") 
    147 */ 
    148120#endif 
  • scolib/trunk/src/lib/PatternSearch.cpp

    r5797 r5803  
    18111811 
    18121812 
    1813  
    1814 namespace StaticInitializers { 
    1815  
    1816 namespace { 
    1817  
    1818 bool RegisterPatternSearch() 
    1819 { 
    1820    colin::SolverMngr().declare_solver_type<PatternSearch> 
    1821       ("scolib:PatternSearch",  
    1822        "A generic pattern search optimizer"); 
    1823  
    1824    colin::SolverMngr().declare_solver_type<PatternSearch> 
    1825       ("scolib:ps", "An alias to scolib:PatternSearch"); 
    1826  
    1827    return true; 
    1828 } 
    1829  
    1830 } // namespace scolib::StaticInitializers::(local) 
    1831  
    1832 extern const volatile bool pattern_serch = RegisterPatternSearch(); 
    1833  
    1834 } // namespace scolib::StaticInitializers 
     1813REGISTER_COLIN_SOLVER_WITH_ALIAS(PatternSearch,"sco:PatternSearch","sco:ps", "The SCO PatternSearch optimizer") 
    18351814 
    18361815} // namespace scolib 
    1837 /* 
    1838 FACTORY_NAMED_REGISTER(ps, "scolib:ps", colin::OptSolverHandle*, 
    1839         return new colin::ConcreteOptSolverHandle<scolib::PatternSearch>;, 
    1840         "An alias to PatternSearch") 
    1841 FACTORY_NAMED_REGISTER(PatternSearch, "scolib:PatternSearch", colin::OptSolverHandle*, 
    1842         return new colin::ConcreteOptSolverHandle<scolib::PatternSearch>;, 
    1843         "A generic pattern search optimizer") 
    1844 */ 
  • scolib/trunk/src/lib/SolisWets.cpp

    r5797 r5803  
    552552 
    553553 
    554 namespace StaticInitializers { 
    555  
    556 namespace { 
    557  
    558 bool RegisterSolisWets() 
    559 { 
    560    colin::SolverMngr().declare_solver_type<SolisWets> 
    561       ("scolib:SolisWets",  
    562        "The derivative-free optimizer of Solis-Wets"); 
    563  
    564    colin::SolverMngr().declare_solver_type<SolisWets> 
    565       ("scolib:sw", "An alias to scolib:SolisWets"); 
    566  
    567    return true; 
    568 } 
    569  
    570 } // namespace scolib::StaticInitializers::(local) 
    571  
    572 extern const volatile bool solis_wets = RegisterSolisWets(); 
    573  
    574 } // namespace scolib::StaticInitializers 
     554REGISTER_COLIN_SOLVER_WITH_ALIAS(SolisWets,"sco:SolisWets","sco:sw", "The SCO SolisWets optimizer") 
    575555 
    576556} // namespace scolib 
    577  
    578 /* 
    579 FACTORY_NAMED_REGISTER(sw, "scolib:sw", colin::OptSolverHandle*, 
    580                 return new colin::ConcreteOptSolverHandle<scolib::SolisWets>;, 
    581                 "An alias to SolisWets") 
    582 FACTORY_NAMED_REGISTER(SolisWets, "scolib:SolisWets", colin::OptSolverHandle*, 
    583                 return new colin::ConcreteOptSolverHandle<scolib::SolisWets>;, 
    584                 "The derivative-free optimizer of Solis-Wets") 
    585 */ 
Note: See TracChangeset for help on using the changeset viewer.