18 #include <utility/exit.hh>
19 #include <utility/pointer/ReferenceCount.hh>
20 #include <utility/pointer/owning_ptr.hh>
24 #include <boost/functional/hash.hpp>
26 #include <ObjexxFCL/format.hh>
27 using namespace ObjexxFCL;
32 #include <utility/vector1.hh>
36 namespace genetic_algorithm {
38 EntityElement::EntityElement() : index_( 0 ) {}
45 Size colon_pos = word.find(
":" );
46 if ( colon_pos == std::string::npos ) {
47 std::cerr <<
"ERROR: Could not find colon (:) in input word while constructing EntityElement. word='" << word <<
"'" << std::endl;
48 utility_exit_with_message(
"EntityElement constructor failure" );
50 std::string indstring = word.substr( 0, colon_pos );
51 std::istringstream iss( indstring );
53 if ( colon_pos + 1 < word.size() ) {
54 word = word.substr( colon_pos + 1 );
88 std::ostringstream oss;
114 core::Size colon_pos = entity_element_name.find(
":" );
118 if ( colon_pos != std::string::npos ) {
119 type = entity_element_name.substr( 0, colon_pos );
120 if ( colon_pos + 1 < entity_element_name.size() ) {
121 desc = entity_element_name.substr( colon_pos + 1 );
124 utility_exit_with_message(
"Invalid EntityElementCreator input; could not locate a colon in the string \"" + entity_element_name +
"\"" );
129 CreatorMap::const_iterator iter = creators().find( type );
130 if ( iter == creators().
end() ) {
131 std::cerr <<
"ERROR: Could not find EntityElement type " << type <<
" in EntityElementFactory" << std::endl;
132 utility_exit_with_message(
"EntityElementFactory type lookup failure" );
134 return iter->second->new_entity( desc );
150 return "EntityElementFactory";
156 utility::pointer::ReferenceCount(),
158 fitness_valid_(false)
163 std::istringstream linestream( line );
164 if ( !
read_checkpoint(linestream) ) utility_exit_with_message(
"invalid string " + line );
168 utility::pointer::ReferenceCount(),
169 traits_( entity.traits_.
size() ),
170 fitness_( entity.fitness_ ),
171 fitness_valid_( entity.fitness_valid_ )
185 if (
this != & rhs ) {
228 if (
traits_.size() == traits.size() ) {
231 *
traits_[ ii ] = *traits[ ii ];
233 traits_[ ii ] = traits[ ii ]->clone();
237 traits_.resize( traits.size() );
239 traits_[ ii ] = traits[ ii ]->clone();
250 traits_[ index ] = element->clone();
297 os <<
"Entity with traits:";
299 for ( EntityElements::const_iterator
300 it( seq.begin() ),
end( seq.end() );
302 os <<
" " << (*it)->to_string();
304 os <<
" and fitness " << fmt::F(6,3,this->
fitness());
313 for ( EntityElements::const_iterator
315 os <<
" " << (*key)->to_string();
326 if (!(is >> word))
return false;
327 if ( word !=
"traits" )
return false;
328 while ( is >> word ) {
329 if ( word ==
"fitness" )
break;