Samchon Framework for CPP  1.0.0
samchon::example::tsp::Travel Class Reference

Represent a travel containning Point(s) More...

#include <Travel.hpp>

Collaboration diagram for samchon::example::tsp::Travel:

Public Member Functions

 Travel ()
 Default Constructor. More...
 
 Travel (const Travel &travel)
 Copy Constructor. More...
 
 Travel (Travel &&travel)
 Move Constructor. More...
 
auto calcDistance () const -> double
 Calculate distance to move. More...
 
auto operator< (const Travel &travel) const -> bool
 Compare which object is less. More...
 
virtual auto TAG () const -> string override
 A tag name when represented by XML. More...
 
virtual auto CHILD_TAG () const -> string override
 A tag name of children. More...
 
virtual auto toXML () const -> shared_ptr< XML > override
 Get an XML object represents the EntityGroup. More...
 
auto toString () const -> string
 Convert the Travel to String. More...
 
- Public Member Functions inherited from samchon::protocol::EntityGroup< _Container, _ETy, T >
 EntityGroup ()
 Default Constructor. More...
 
virtual void construct (std::shared_ptr< library::XML > xml)
 Construct data of the Entity from an XML object. More...
 
auto has (const std::string &key) const -> bool
 Indicates whether a container has an object having the specified identifier. More...
 
auto get (const std::string &key) -> value_type &
 Access the element by specified identifier(key). More...
 
auto get (const std::string &key) const -> const value_type &
 Access the const element by specified identifier(key). More...
 
- Public Member Functions inherited from samchon::protocol::Entity
 Entity ()
 Default Constructor. More...
 
virtual auto key () const -> std::string
 Get a key that can identify the Entity uniquely. More...
 
- Public Member Functions inherited from samchon::protocol::IEntityGroup
 IEntityGroup ()
 Default Constructor. More...
 

Protected Attributes

double distance
 Estimated hours to move. More...
 

Additional Inherited Members

- Protected Member Functions inherited from samchon::protocol::EntityGroup< _Container, _ETy, T >
virtual auto createChild (std::shared_ptr< library::XML >) -> entity_type *=0
 Factory method of a child Entity. More...
 

Detailed Description

Represent a travel containning Point(s)

Travel class is not only an array containing Point(s) but also a sequence listing of the Point(s).

example_tsp.png
Author
Jeongho Nam http://samchon.org

Definition at line 27 of file Travel.hpp.

Constructor & Destructor Documentation

samchon::example::tsp::Travel::Travel ( )
inline

Default Constructor.

Definition at line 49 of file Travel.hpp.

samchon::example::tsp::Travel::Travel ( const Travel travel)
inline

Copy Constructor.

Travel is an array of Point(s) as gene(s). The copy constructor of Travel doesn't copy member variables which are related to G.A. because the sequence of gene(Point)s can be shuffled by process of evolution of genetic algorithm.

Definition at line 63 of file Travel.hpp.

samchon::example::tsp::Travel::Travel ( Travel &&  travel)
inline

Move Constructor.

Definition at line 72 of file Travel.hpp.

Member Function Documentation

auto samchon::example::tsp::Travel::calcDistance ( ) const -> double
inline

Calculate distance to move.

Definition at line 103 of file Travel.hpp.

auto samchon::example::tsp::Travel::operator< ( const Travel travel) const -> bool
inline

Compare which object is less.

Compares distances to move. The result is used to optimize and evolve genes by G.A.

Parameters
Targetobject to compare
Returns
Whether this object is less than target

Definition at line 124 of file Travel.hpp.

virtual auto samchon::example::tsp::Travel::TAG ( ) const -> string
inlineoverridevirtual

A tag name when represented by XML.

Returns
A tag name

Implements samchon::protocol::Entity.

Definition at line 132 of file Travel.hpp.

virtual auto samchon::example::tsp::Travel::CHILD_TAG ( ) const -> string
inlineoverridevirtual

A tag name of children.

< TAG>
     <CHILD_TAG />
     <CHILD_TAG />
</TAG>

Implements samchon::protocol::IEntityGroup.

Definition at line 136 of file Travel.hpp.

virtual auto samchon::example::tsp::Travel::toXML ( ) const -> shared_ptr<XML>
inlineoverridevirtual

Get an XML object represents the EntityGroup.

Archives the EntityGroup's own member variables only to the returned XML object.

Do not consider about archiving children Entity objects' data in EntityGroup::toXML(). Those children Entity objects will converted to XML object by their own toXML() method. The insertion of XML objects representing children are done by abstract method of EntityGroup::toXML().

Archives only data of EntityGroup's own.

[Inherited]
Get an XML object represents the Entity.

Returns an XML object that can represents the Entity containing member variables into properties.

A member variable (not object, but atomic value like number, string or date) is categorized as a property within the framework of entity side. Thus, when overriding a toXML() method and archiving member variables to an XML object to return, puts each variable to be a property belongs to only an XML object.

Don't archive the member variable of atomic value to XML::value causing enormouse creation of XML objects to number of member variables. An Entity must be represented by only an XML instance (tag).

Standard Usage Non-standard usage abusing value
<memberList>
     <member id='jhnam88' name='Jeongho+Nam' birthdate='1988-03-11' />
     <member id='master' name='Administartor' birthdate='2011-07-28' />
</memberList>
<member>
     <id>jhnam88</id>
     <name>Jeongho+Nam</name>
     <birthdate>1988-03-11</birthdate>
</member>
Returns
An XML object representing the Entity.

Reimplemented from samchon::protocol::EntityGroup< _Container, _ETy, T >.

Definition at line 141 of file Travel.hpp.

auto samchon::example::tsp::Travel::toString ( ) const -> string
inline

Convert the Travel to String.

Have of form of tab and enter delimeters for Excel.

 {$uid1}    {$x}    {$y} 


 {$uid2}   {$x}    {$y} 


 {$uid3}   {$x}    {$y} 


...

Returns
A string can represent the Travel

Definition at line 162 of file Travel.hpp.

References samchon::library::StringUtil::numberFormat().

Here is the call graph for this function:

Member Data Documentation

double samchon::example::tsp::Travel::distance
protected

Estimated hours to move.

A variable for avoiding duplicated calculation

See also
calcDistance()

Definition at line 40 of file Travel.hpp.


The documentation for this class was generated from the following file: