SparkseePython  6.0.2
Public Member Functions | List of all members
sparksee.KOpt Class Reference

KOpt class. More...

Public Member Functions

def __init__ (self, session, tour)
 Creates a new instance. More...
 
def set_current_tour (self, tour)
 Sets current tour as a list of nodes. More...
 
def get_current_cost (self)
 Returns tour cost.
 
def add_all_edge_types (self, dir)
 Allows for traversing all edge types of the graph. More...
 
def get_current_tour (self)
 Returns tour as a list of nodes.
 
def set_edge_weight_attribute_type (self, attr)
 Sets the attribute to use as edge weight. More...
 
def run_two_opt (self)
 Runs 2-Opt local search.
 
def add_edge_type (self, type, dir)
 Allows for traversing edges of the given type. More...
 
def run_three_opt (self)
 Runs 3-Opt local search.
 
def set_max_iterations (self, max_iterations)
 Sets maximum number of iterations. More...
 
def set_time_limit (self, max_time)
 Limits execution time. More...
 
def add_node_type (self, type)
 Allows for traversing nodes of the given type. More...
 
def __init__ (self, session)
 Creates a new instance. More...
 
def add_all_node_types (self)
 Allows for traversing all node types of the graph.
 

Detailed Description

KOpt class.

Implements the 2-Opt and 3-Opt algorithms

Author
Sparsity Technologies http://www.sparsity-technologies.com

Constructor & Destructor Documentation

def sparksee.KOpt.__init__ (   self,
  session,
  tour 
)

Creates a new instance.

Parameters
session[in] Session to get the graph from and perform algorithm.
tour[in] Initial tour that needs to be improved.

Referenced by sparksee.KOpt.__init__().

def sparksee.KOpt.__init__ (   self,
  session 
)

Creates a new instance.

Parameters
session[in] Session to get the graph from and perform algorithm.

References sparksee.KOpt.__init__().

Member Function Documentation

def sparksee.KOpt.add_all_edge_types (   self,
  dir 
)

Allows for traversing all edge types of the graph.

Parameters
dir[in] Edge direction.
def sparksee.KOpt.add_edge_type (   self,
  type,
  dir 
)

Allows for traversing edges of the given type.

If the edge type was already added, the existing direction is overwritten

Parameters
type[in] Edge type.
dir[in] Edge direction.
Exceptions
RuntimeErrornull
def sparksee.KOpt.add_node_type (   self,
  type 
)

Allows for traversing nodes of the given type.

sparksee::gdb::Error

Parameters
type[in] Node type.
Exceptions
RuntimeErrornull
def sparksee.KOpt.set_current_tour (   self,
  tour 
)

Sets current tour as a list of nodes.

Parameters
tour[in] Initial tour that needs to be improved.
def sparksee.KOpt.set_edge_weight_attribute_type (   self,
  attr 
)

Sets the attribute to use as edge weight.

If the multiple edge are set for traversal, this attribute must be of type GLOBAL_TYPE or EDGES_TYPE. Additionally, the attribute must be of type Double.

sparksee::gdb::Error

Parameters
attr[in] The attribute type to use as a weight. Default: InvalidAttribute
Exceptions
RuntimeErrornull
def sparksee.KOpt.set_max_iterations (   self,
  max_iterations 
)

Sets maximum number of iterations.

By default the algorithm will run until no improvement can be made in the current tour.

Parameters
max_iterations[in] Maximum number of iterations
def sparksee.KOpt.set_time_limit (   self,
  max_time 
)

Limits execution time.

Parameters
max_time[in] Time limit in miliseconds