Skip to main content

KAIST CS453 2019 Spring Team 7 Project

Project description

Coding Test Input Generator

CoTeGen automatically generates test suite of a typical coding test problem from the bottom. First, an initial test suite can be constructed with minimal cost. Next, search-based input generation with mutation fitness complement the initial test suite. Using mutated reference solution as a simplified form of wrong answers, we aim to kill as many mutants as possible. Hence, mutation coverage is provided as a complementary result.

Adding New Reference Solution

After installing our cotegen package, You can write a new reference solution as a simple python file to generate corresponding test cases.

Please locate your reference solution file in examples/tasks directory to utilize command line execution.

You should define a new class inherits cotegen.Task and with the same with filename.

input_parameters, solve(reference solution), compare, and convert_input_to_string are essential methods to override.

Please refer the example:

import cotegen

# http://codeforces.com/problemset/problem/1/A

class CF1A(cotegen.Task):
    input_parameters = \
        {
            'n': cotegen.types.Integer(1, 10**9),
            'm': cotegen.types.Integer(1, 10**9),
            'a': cotegen.types.Integer(1, 10**9),
        }

    def solve(n: int, m: int, a: int) -> int:
        # 1 <= n, m, a <= 10**9
        return ((n + (a-1)) // a) * ((m + (a-1)) // a)

    @staticmethod
    def compare(user_answer: int, jury_answer: int) -> bool:
        return user_answer == jury_answer

    @staticmethod
    def convert_input_to_string(n: int, m: int, a: int):
        return "%d %d %d\n" % (n, m, a)


if __name__ == '__main__':
    import os
    CF1A.generate_test_files(os.path.expanduser("~/Downloads/CS453/CF1A"))

Define Input Parameters

Predefine the types of input parameters and the range of each argument as a dictionary format.

Currently, CoTeGen supports following types:

cotegen.types.Integer
cotegen.types.IntegerSequence
cotegen.types.NonIncreasingIntegerSequence
cotegen.types.FixedVariableLengthIntegerSequence
cotegen.types.IntegerPermutation

Define constraint

If needed, define the constraints among input parameters as list.

constraints = [
        cotegen.constraints.Leq('M', 'N')
    ]

You can utilize these predefined constraints:

cotegen.constraints.Leq (Less than or equal)
cotegen.constraints.ListLengthLeqInteger
cotegen.constraints.ListLengthReqInteger

or, use custom constraints giving custom function (which receives parameter dictionary and returns true/false) as an argument

cotegen.constraints.CustomConstraint(lambda test: 'd1' not in test or 'd2' not in test or test['d1'] != test['d2'])

Command Line Usage

python -m cotegen run random --filename <filename>

python -m cotegen run mutation --filename <filename> --show-survived <true or false>

python -m cotegen run kill --filename <filename> --save <directory path> --mutation-fitness <true or false>

For example:

python -m cotegen run random --filename CF158A

python -m cotegen run mutation --filename CF158A

python -m cotegen run kill --filename CF158A --save ~/Downloads --mutation-fitness true

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

cotegen-1.1.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

cotegen-1.1-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file cotegen-1.1.tar.gz.

File metadata

  • Download URL: cotegen-1.1.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.1

File hashes

Hashes for cotegen-1.1.tar.gz
Algorithm Hash digest
SHA256 85d2fe84b1658867978bf9c47f24a272d525e41077fc79e53379af663f315188
MD5 88622e2a598867e225fed9f90e5ce77c
BLAKE2b-256 26d8c8f19eb47b074f740f325b51caf7504c3295583227e474c2893c415982e7

See more details on using hashes here.

File details

Details for the file cotegen-1.1-py3-none-any.whl.

File metadata

  • Download URL: cotegen-1.1-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.1

File hashes

Hashes for cotegen-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb090de064405e9e958a57d4d8527a18e718de04c0db342fa01c0cabbbc98ba5
MD5 a0387b2db07ccc887c0246ac4b27c091
BLAKE2b-256 62eccd23f6b460cce1fab15f1a61fc65f07bce610f8cbdf9c2a6dd58d9b3b88f

See more details on using hashes here.

Supported by

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