Пример #1
0
    def create( spec, K=1, scheme = 'none', count = 20, *args ):
        """
        @spec - Specification (size, endpoints, barriers); either exactly
                specified in a file, or with numeric values in a list
        @option_scheme - none|manual|optimal|small-world|random|ozgur's betweenness|ozgur's randomness|end
        @n_actions - Number of steps that need to taken
        comment : optimal(shortest path to destination)??|random|ozgur's betweenness|ozgur's randomness
        """

        env = Rooms.create( spec, K )

        # Percentage
        if isinstance(count,str):
            count = int(count[:-1])
            count = count*env.S/100

        # Add options for all the optimal states
        O = []
        if scheme == "none":
            pass
        elif scheme == "random-node":
            O = OptionGenerator.optimal_options_from_random_nodes( env, count, *args )
        elif scheme == "random-path":
            O = OptionGenerator.optimal_options_from_random_paths( env, count, *args )
        elif scheme == "betweenness":
            O = OptionGenerator.optimal_options_from_betweenness( env, count, *args )
        elif scheme == "small-world":
            O = OptionGenerator.optimal_options_from_small_world( env, count, *args )
        elif scheme == "ultra-small-world":
            O = OptionGenerator.optimal_options_from_ultra_small_world( env, count, *args )
        elif scheme == "betweenness+small-world":
            O = OptionEnvironment.optimal_options_from_betweenness( env, count )
            count_ = count - len( O ) 
            O += OptionEnvironment.optimal_options_from_small_world( env, count_, *args )
        elif scheme == "load":
            O = OptionGenerator.options_from_file( count, *args )
        else:
            raise NotImplemented() 

        return OptionEnvironment( RoomsOptions, env.S, env.A, env.P, env.R, env.R_bias, env.start_set, env.end_set, O )
Пример #2
0
def db_test(config):
  test_user = {
    "username" : "test"
    , "password" : "29148931"
    , "salt" : "1234"
    , "admin" : "1"
  }
  users = Users()
  users.create()
  users.save(test_user)

  test_room = {
    "room_id" : "seka"
    , "password" : "29148931"
  }
  test_room2 = {
    "room_id" : "test"
    , "password" : "29148931"
  }

  rooms = Rooms()
  rooms.create()
  rooms.save(test_room)
  rooms.save(test_room2)

  test_entry = {
    "room_id" : "seka"
    , "entry" : u"この内容はテストです"
    , "type"  : "keep"
    , "good"  : 4
  }
  test_entry2 = {
    "room_id" : "seka"
    , "entry" : u"この内容はテストです"
    , "type"  : "try"
    , "good"  : 5
  }

  entries = Entry()
  entries.create()
  entries.save(test_entry)
  entries.save(test_entry)
  entries.save(test_entry)
  entries.save(test_entry2)
  entries.save(test_entry2)

  goods = Goods()
  goods.create()

  test_comment = {
    "kpt_id" : 1
    , "text" : u"テストのコメントです"
  }

  test_comment2 = {
    "kpt_id" : 1
    , "text" : u"テストのコメントです2"
  }
  test_comment3 = {
    "kpt_id" : 2
    , "text" : u"テスト2のコメントです"
  }

  comments = Comments()
  comments.create()
  comments.save(test_comment)
  comments.save(test_comment2)
  comments.save(test_comment3)
import OptionGenerator
from Rooms import Rooms

class RoomsOptions( ):

    @staticmethod
    def create( spec, K=1 scheme = 'none', count = 20, *args ):
        """
        @spec - Specification (size, endpoints, barriers); either exactly
                specified in a file, or with numeric values in a list
        @option_scheme - none|manual|optimal|small-world|random|ozgur's betweenness|ozgur's randomness|end
        @n_actions - Number of steps that need to taken
        comment : optimal(shortest path to destination)??|random|ozgur's betweenness|ozgur's randomness
        """

        env = Rooms.create( spec, K )

        # Percentage
        if isinstance(count,str):
            count = int(count[:-1])
            count = count*env.S/100

        # Add options for all the optimal states
        O = []
        if scheme == "none":
            pass
        elif scheme == "random-node":
            O = OptionGenerator.optimal_options_from_random_nodes( env, count, *args )
        elif scheme == "random-path":
            O = OptionGenerator.optimal_options_from_random_paths( env, count, *args )
        elif scheme == "betweenness":
Пример #4
0
import OptionGenerator
from Rooms import Rooms

class RoomsOptions( ):

    @staticmethod
    def create( spec, K=1 scheme = 'none', count = 20, *args ):
        """
        @spec - Specification (size, endpoints, barriers); either exactly
                specified in a file, or with numeric values in a list
        @option_scheme - none|manual|optimal|small-world|random|ozgur's betweenness|ozgur's randomness|end
        @n_actions - Number of steps that need to taken
        comment : optimal(shortest path to destination)??|random|ozgur's betweenness|ozgur's randomness
        """

        env = Rooms.create( spec, K )

        # Percentage
        if isinstance(count,str):
            count = int(count[:-1])
            count = count*env.S/100

        # Add options for all the optimal states
        O = []
        if scheme == "none":
            pass
        elif scheme == "random-node":
            O = OptionGenerator.optimal_options_from_random_nodes( env, count, *args )
        elif scheme == "random-path":
            O = OptionGenerator.optimal_options_from_random_paths( env, count, *args )
        elif scheme == "betweenness":