Git Product home page Git Product logo

chokudai3's Introduction

Education-Week-MM

This repository is my history of the development of a program for Education Week MM. I mainly tried to solve this problem based on Hill Climbing (HC) approach and Simulated Annealing (SA) approach.

Resources

Problem: https://community.topcoder.com/longcontest/?module=ViewProblemStatement&rd=16997&pm=14690

Standings: https://community.topcoder.com/longcontest/?module=ViewStandings&rd=16997

Google spreadsheets

Analysis for my solution: https://docs.google.com/spreadsheets/d/1-PTRg_Xf_O9qzIGzw3JzSuv0gfLR_74fFDSvBZ4VhoA/edit?usp=sharing

Pre & final results: https://docs.google.com/spreadsheets/d/1x_Fw4YIKTBzckW3tP_3StDez_oGyzaOa1njbBd9K4EU/edit?usp=sharing

Score transition

  1. 806455.16 HC (with incremental update) (#6)
  2. 820439.30 SA(*) (with a sorted array as the initial solution) (#23)
  3. 822360.59 HC (with changing one element instead of swapping a pair) (#28)
  4. 822365.58 HC (the same as 3. except that used time increased 8.75s to 9.4s) (#31)
  5. 822393.73 SA (with tuned parameters and changed timer) (#37)

(*) To use SA was not important at that time (refer to #24)

Key Observations

  • Actually sorted array [0,1,...,n-1] is very good initial solution.
  • Encoding magnitude relations between pairs of position to a directed graph.
  • Encoding permutation as real numbers of 32(or anything enough)-bit integers. (#26)
    • This makes transition more flexible.
    • This increases the number of iterations beecause it's fast in terms of constant optimization.
  • Incremental update when change the value at position k with the time complexity of O(∑|Edges connected to k|).
  • Hill climbling allowing to transit with zero score improvement or Simulated annealing.

Other observations

  • You can find the best value to assign with O(∑|Edges connected to k|) log ∑|Edges connected to k|)
    • Sort current values and then use accumulated sum technique to specify the range of values you can achieve maximum increase. (#33)

How to compile main.cpp

g++ main.cpp -O3 std=c++14 -DLOCAL [-DDEBUG] [-DANALYSIS] [-DENABLE_DIZZY_ANALYSIS] [-DNO_OUTPUT]

  • -DDEBUG enables assertions and to show the outputs for LOG().

  • -DANALYSIS enables to show ANALYSIS_LOG(), which is for not fequent logging like final score.

  • -DENABLE_DIZZY_ANALYSIS enables to show DIZZY_ANALYSIS_LOG(), which is for frequent logging like current score at each time

  • -DNO_OUTPUT disables to output answer.

Scripts

  • localtest.sh tests main.cpp with seed 1 to 100 and store the logs for each test case.
  • run.sh exec_file input_file is for testing exec_file with input_file. The log will be stored into ./log/ and ./output by default. You can change the directory by specifying LOG_DIR and OUTPUT_DIR.
  • input_generator.sh generates input files of seed 1 to 100 to ./test_inputs/ directory.
  • generate_submittable_code.sh generates the auto formatted code for main.cpp and save as frozen.cpp.
  • build_result_from_log.sh log_dir converts all raw logs in log_dir into a structured csv file.
  • recent_log.sh is just a useful command to build a structured csv file for the recent local test.
  • csv_builder.py log_file is a faster way to build structured csv file, but no longer used due to its low flexibility.

chokudai3

chokudai3's People

Contributors

kyuridenamida avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.