Skip to main content

Ramsey Number Explorer

Project description

Ramsey Theory RL

About

Ramsey Theory RL is a project that seeks to use simple RL and a basic graph invariant to pseudo-intelligently search for counterexamples for unknown Ramsey number bounds. The main aims of the project are to either improve the bounds or to assist in finding more isomorphic graphs for known numbers to help future efforts.

Our algorithm is an informed Best First Search. At each iteration, all neighbors (1 changed edge away) to the current graph are numerically represented by their invariant. The invariant is counts of all 11 possible isomorphic 4-graphs inside of them. The neighbors with invariants not yet expanded are then passed through a heuristic which determines which graph to expand next. Past literature has used the count of 4-paths as a heuristic. We use a DNN with 1 hidden layer that we iteratively train on seen graphs, to encourage straying away from known areas.

The algorithm can pretrain on known graphs and can start from a random graphs, known counterexamples from a smaller $n$, and known counterexamples from the same $n$. Logging is done through neptune.ai.

Our algorithm has a runtime of O($n^2 * n^{\min({4,s,t})}$) per step. As such, values like R(3,10) are less practical to explore, and so our current focus is on R(4,6) and R(5,5).

Getting Started

  • Sign up with Neptune AI

  • Create a project called RamseyRL with a model called RAM-HEUR

  • Get your Neptune API token and name

  • Run the following

    Installing Packages

    pip install RamseyTheoryRL
    pip install -r https://raw.githubusercontent.com/aLehav/RamseyTheoryRL/main/RamseyTheoryRL/requirements.txt --quiet
    

    Setting Environment Variables

    import os
    # Change these for your real token and username
    os.environ['NEPTUNE_API_TOKEN'] = 's0me!l0nGn3pTunEt0k3N='
    os.environ['NEPTUNE_NAME'] = 'yourname'
    

    Setting Parameters and Path

    from RamseyTheoryRL.src.ramsey_checker.test import NeptuneRunner
    import tensorflow as tf
    
    def project_fetcher():
        return f"{os.environ.get('NEPTUNE_NAME')}/RamseyRL"
    
    runner = NeptuneRunner(n=36, s=4, t=6, project=project_fetcher())
    
    new_params = runner.PARAMS
    changed_vals = {'iter_batch':20,
                    'iter_batches':50,
                    'starting_graph':"FROM_CURRENT",
                    'starting_graph_path':'/data/found_counters/r4_5_24_isograph.g6'
                    }
    new_params.update(changed_vals)
    runner.update_params(new_params)
    

    Running

    runner.run()
    

    (Optional) Running for all Prior Graphs

    # Getting max index of starting graph
    # Only to be used when PARAMS['starting_graph] in ["FROM_PRIOR", "FROM_CURRENT"]
    import sys
    import networkx as nx
    
    def get_max_starting_index(runner):
      counters = nx.read_graph6(sys.path[-1] + runner.PARAMS['starting_graph_path'])
      counters = [counters] if type(counters) != list else counters
      return len(counters)
    
    for i in range(get_max_starting_index(runner)):
      runner.PARAMS['starting_graph_index'] = i
      runner.run()
    

Full Parameter Description

  • heurstic_type: Choose from RANDOM, 4PATH, DNN, SCALED_DNN
  • iter_batch: Steps to take before updating model data / weights
  • iter_batches: None if no stopping value, else num. of iter_batches
  • starting_graph: Choose from RANDOM, FROM_PRIOR, FROM_CURRENT, EMPTY
  • starting_graph_path: Path to starting graph
  • starting_graph_index: Index of starting graph within starting graph index list
  • starting_edges: Add new edges if starting FROM_PRIOR
  • load_model: Whether or not to load a past version of the model
  • profiler: Enable profiler
  • model: If passed, when using SCALED_DNN or DNN heuristic, the default model of a DNN with hidden layers of size 32, 16, and then 1 with optimizer=params['optimizer'], loss=params['loss'], metrics=['accuracy'] can be overridden for any tf model that has already had model.compile called
  • training_epochs: If pretraining on data, the number of epochs to train for
  • pretrain: Whether or not pretraining occurs
  • pretrain_data: A list of preprocessed csv's to be trained on
  • epochs: Epochs to update the model for after each iteration of training
  • batch_size: Batch size for training
  • loss_info: Info regarding loss used, improves logging readability
  • alpha: Learning rate for DNN (i.e. if a counter was found k steps ago, a point that isn't a counter in this iteration would have a value of $\alpha^k$)

Future Changes

  • Improving documentation and usability
  • Removing and rearranging older content
  • Integrating pip package to Getting Started portion

Contributors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

RamseyTheoryRL-0.83.tar.gz (12.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

RamseyTheoryRL-0.83-py3-none-any.whl (12.1 MB view details)

Uploaded Python 3

File details

Details for the file RamseyTheoryRL-0.83.tar.gz.

File metadata

  • Download URL: RamseyTheoryRL-0.83.tar.gz
  • Upload date:
  • Size: 12.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for RamseyTheoryRL-0.83.tar.gz
Algorithm Hash digest
SHA256 1d03d02e0a149fb005f4358d79ea9b2b6da4fc6a3a29de522b99794254c2dd6f
MD5 9f916a7eada636c4cd3b6abfe32ebdc5
BLAKE2b-256 fc30c0d848a233b60df1dc77fdf079c68d7aa22aeac413e2ec7cdc33fd70c6cf

See more details on using hashes here.

File details

Details for the file RamseyTheoryRL-0.83-py3-none-any.whl.

File metadata

  • Download URL: RamseyTheoryRL-0.83-py3-none-any.whl
  • Upload date:
  • Size: 12.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for RamseyTheoryRL-0.83-py3-none-any.whl
Algorithm Hash digest
SHA256 48066efd684bf3e87b711f8ac3f681eacac5c69e4ddf2e7c20f3e6afc09aadf0
MD5 47c29469c9851e0a1c4aa778f95e08d9
BLAKE2b-256 0dce52ba11875c9ed0791191378eb698ed07844052e6ca3c821de4e5f48a4b52

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page