Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Diff of /trunk/gadget/optinfopso.cc
[mareframe] / trunk / gadget / optinfopso.cc Repository:
ViewVC logotype

Diff of /trunk/gadget/optinfopso.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 27, Mon May 8 11:58:23 2017 UTC revision 28, Wed Jul 5 12:08:06 2017 UTC
# Line 6  Line 6 
6  OptInfoPso::OptInfoPso()  OptInfoPso::OptInfoPso()
7    : OptInfo(),  goal(1e-5), psoiter(100000), c1(1.496), c2(1.496),    : OptInfo(),  goal(1e-5), psoiter(100000), c1(1.496), c2(1.496),
8          w_max(PSO_INERTIA), w_min(0.3), clamp_pos(1), nhood_strategy(PSO_NHOOD_RING),          w_max(PSO_INERTIA), w_min(0.3), clamp_pos(1), nhood_strategy(PSO_NHOOD_RING),
9          nhood_size(5), w_strategy(PSO_W_LIN_DEC)          nhood_size(5), w_strategy(PSO_W_LIN_DEC), scale(0)
10       {       {
11    type = OPTPSO;    type = OPTPSO;
12    handle.logMessage(LOGMESSAGE, "Initialising PSO optimisation algorithm");    handle.logMessage(LOGMESSAGE, "Initialising PSO optimisation algorithm");
# Line 15  Line 15 
15  void OptInfoPso::read(CommentStream& infile, char* text) {  void OptInfoPso::read(CommentStream& infile, char* text) {
16    handle.logMessage(LOGMESSAGE, "Reading PSO optimisation parameters");    handle.logMessage(LOGMESSAGE, "Reading PSO optimisation parameters");
17    
18    unsigned s1 = 0;  //  unsigned s1 = 0;
19    unsigned s2 = 0;  //  unsigned s2 = 0;
20    unsigned s3 = 0;  //  unsigned s3 = 0;
21    
22    int count = 0;    int count = 0;
23    while (!infile.eof() && strcasecmp(text, "[PSO]") && strcasecmp(text, "[simann]") && strcasecmp(text, "[hooke]") && strcasecmp(text, "[bfgs]")) {    while (!infile.eof() && strcasecmp(text, "[PSO]") && strcasecmp(text, "[simann]") && strcasecmp(text, "[hooke]") && strcasecmp(text, "[bfgs]")) {
# Line 25  Line 25 
25      if (strcasecmp(text, "seed") == 0) {      if (strcasecmp(text, "seed") == 0) {
26        int s = 0;        int s = 0;
27        infile >> s >> ws;        infile >> s >> ws;
28        s1 = s;  //      s1 = s;
29        handle.logMessage(LOGMESSAGE, "Initialising random number generator with", s);        handle.logMessage(LOGMESSAGE, "Initialising random number generator with", s);
30        srand(s1);        srand(s);
31          }          }
32      else if (strcasecmp(text, "psoiter") == 0) {      else if (strcasecmp(text, "psoiter") == 0) {
33        infile >> psoiter;        infile >> psoiter;
# Line 71  Line 71 
71        infile >> size;        infile >> size;
72        count++;        count++;
73    
74        } else if (strcasecmp(text, "scale") == 0) {
75            infile >> scale;
76            count++;
77    
78      } else {      } else {
79        handle.logMessage(LOGINFO, "Warning in optinfofile - unrecognised option", text);        handle.logMessage(LOGINFO, "Warning in optinfofile - unrecognised option", text);
80        infile >> text;  //read and ignore the next entry        infile >> text;  //read and ignore the next entry
# Line 94  Line 98 
98          handle.logMessage(LOGINFO, "Warning in optinfofile - Invalid w_strategy. Setting to default PSO_W_LIN_DEC");          handle.logMessage(LOGINFO, "Warning in optinfofile - Invalid w_strategy. Setting to default PSO_W_LIN_DEC");
99          w_strategy=PSO_W_LIN_DEC;          w_strategy=PSO_W_LIN_DEC;
100    }    }
101    
102      if (scale != 0 && scale != 1) {
103          handle.logMessage(LOGINFO, "Warning in optinfofile - value of scale outside bounds", scale);
104          scale = 0;
105        }
106  }  }
107    
108  void OptInfoPso::Print(ofstream& outfile, int prec) {  void OptInfoPso::Print(ofstream& outfile, int prec) {

Legend:
Removed from v.27  
changed lines
  Added in v.28

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge