示例#1
0
                        help="log debug messages (same as -vv)")
    args = parser.parse_args()

    if args.verbose == 0:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.INFO)
    elif args.verbose == 1:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.VERBOSE)
    elif args.verbose > 1:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.DEBUG)
        ugp4.logging.debug("Verbose level set to DEBUG")

    ugp4.logging.log_cpu(ugp4.logging.INFO, "Program started")

    generic = ugp4.make_parameter(ugp4.parameter.LocalReference,
                                  allow_self=True,
                                  allow_forward=True,
                                  allow_backward=True,
                                  frames_up=1)
    forward_only = ugp4.make_parameter(ugp4.parameter.LocalReference,
                                       allow_self=False,
                                       allow_forward=True,
                                       allow_backward=False,
                                       frames_up=1)
    forward_only_loose = ugp4.make_parameter(ugp4.parameter.LocalReference,
                                             allow_self=False,
                                             allow_forward=True,
                                             allow_backward=False,
                                             frames_up=1)
    backward_only = ugp4.make_parameter(ugp4.parameter.LocalReference,
                                        allow_self=False,
                                        allow_forward=False,
示例#2
0
                        const=2,
                        help="log debug messages (same as -vv)")
    args = parser.parse_args()

    if args.verbose == 0:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.INFO)
    elif args.verbose == 1:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.VERBOSE)
    elif args.verbose > 1:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.DEBUG)
        ugp4.logging.debug("Verbose level set to DEBUG")

    # Local References
    generic = ugp4.make_parameter(ugp4.parameter.LocalReference,
                                  allow_self=True,
                                  allow_forward=True,
                                  allow_backward=True,
                                  frames_up=1)
    forward_only = ugp4.make_parameter(ugp4.parameter.LocalReference,
                                       allow_self=False,
                                       allow_forward=True,
                                       allow_backward=False,
                                       frames_up=1)
    forward_loose = ugp4.make_parameter(ugp4.parameter.LocalReference,
                                        allow_self=False,
                                        allow_forward=True,
                                        allow_backward=False,
                                        frames_up=1)
    backward_only = ugp4.make_parameter(ugp4.parameter.LocalReference,
                                        allow_self=False,
                                        allow_forward=False,
示例#3
0
                        const=2,
                        help="log debug messages (same as -vv)")
    args = parser.parse_args()

    if args.verbose == 0:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.INFO)
    elif args.verbose == 1:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.VERBOSE)
    elif args.verbose > 1:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.DEBUG)
        ugp4.logging.debug("Verbose level set to DEBUG")

    ugp4.logging.log_cpu(ugp4.logging.INFO, "Program started")

    # Define parameters ________________________________________________________________________________________________
    registers = ugp4.make_parameter(ugp4.parameter.Categorical,
                                    alternatives=['ax', 'bx', 'cx', 'dx'])
    # cat_sor = ugp4.make_parameter(ugp4.parameter.CategoricalSorted,
    #                              alternatives=['e', 'f', 'g', 'h', 'i', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't'])
    int256 = ugp4.make_parameter(ugp4.parameter.Integer, min=0, max=256)
    # word8 = ugp4.make_parameter(ugp4.parameter.Bitstring, len_=8)
    ref_fwd = ugp4.make_parameter(ugp4.parameter.LocalReference,
                                  allow_self=False,
                                  allow_forward=True,
                                  allow_backward=False,
                                  frames_up=1)
    ref_bcw = ugp4.make_parameter(ugp4.parameter.LocalReference,
                                  allow_self=False,
                                  allow_forward=False,
                                  allow_backward=True,
                                  frames_up=1)
示例#4
0
                        dest='verbose',
                        const=2,
                        help="log debug messages (same as -vv)")
    args = parser.parse_args()
    if args.verbose == 0:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.INFO)
    elif args.verbose == 1:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.VERBOSE)
    elif args.verbose > 1:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.DEBUG)
        ugp4.logging.debug("Verbose level set to DEBUG")
    ugp4.logging.log_cpu(ugp4.logging.INFO, "Program started")

    # Define parameters
    reg_alternatives = ['%eax', '%ebx', '%ecx', '%edx']
    reg_param = ugp4.make_parameter(ugp4.parameter.Categorical,
                                    alternatives=reg_alternatives)
    instr_alternatives = ['add', 'sub', 'and', 'or', 'xor', 'cmp']
    instr_param = ugp4.make_parameter(ugp4.parameter.Categorical,
                                      alternatives=instr_alternatives)
    shift_alternatives = ['shr', 'shl']
    shift_param = ugp4.make_parameter(ugp4.parameter.Categorical,
                                      alternatives=shift_alternatives)
    jmp_alternatives = [
        'ja', 'jz', 'jnz', 'je', 'jne', 'jc', 'jnc', 'jo', 'jno', 'jmp'
    ]
    jmp_instructions = ugp4.make_parameter(ugp4.parameter.Categorical,
                                           alternatives=jmp_alternatives)
    integer = ugp4.make_parameter(ugp4.parameter.Integer,
                                  min=-32768,
                                  max=32767)
    int8 = ugp4.make_parameter(ugp4.parameter.Integer, min=0, max=256)
示例#5
0
                        action="store_const",
                        dest="verbose",
                        const=2,
                        help="log debug messages (same as -vv)")
    args = parser.parse_args()
    if args.verbose == 0:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.INFO)
    elif args.verbose == 1:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.VERBOSE)
    elif args.verbose > 1:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.DEBUG)
        ugp4.logging.debug("Verbose level set to DEBUG")
    ugp4.logging.log_cpu(ugp4.logging.INFO, "Program started")

    # Define a parameter of type ugp4.parameter.Categorical that can take two values: 0 or 1
    bit = ugp4.make_parameter(ugp4.parameter.Categorical, alternatives=[0, 1])

    # Define a macro that contains a parameter of type ugp4.parameter.Categorical
    word_macro = ugp4.Macro("{bit}", {'bit': bit})

    # Create a section containing 8 macros
    word_section = ugp4.make_section(word_macro, size=(8, 8), name='word_sec')

    # Create a constraints library
    library = ugp4.Constraints()
    library['main'] = ["Bitstring:", word_section]

    # Define the evaluator method and the fitness type
    def evaluator_function(data: str):
        count = data.count('1')
        return list(str(count))
示例#6
0
                        action='store_const',
                        dest='verbose',
                        const=2,
                        help="log debug messages (same as -vv)")
    args = parser.parse_args()
    if args.verbose == 0:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.INFO)
    elif args.verbose == 1:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.VERBOSE)
    elif args.verbose > 1:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.DEBUG)
        ugp4.logging.debug("Verbose level set to DEBUG")

    ugp4.logging.log_cpu(ugp4.logging.INFO, "Program started")
    # Define a parameter of type ugp4.parameter.Bitstring and length = 8
    bitstring = ugp4.make_parameter(ugp4.parameter.Bitstring, len_=64)
    # Define a macro that contains a parameter of type ugp4.parameter.Bitstring
    word_macro = ugp4.Macro("{x}", {'x': bitstring})
    # Create a section containing a macro
    word_section = ugp4.make_section(word_macro, size=(1, 1), name='word_sec')
    # Create a constraints library
    library = ugp4.Constraints()
    # Define the sections in the library
    library['main'] = [word_macro]
    # Fitness (simple)
    library.evaluator = ugp4.fitness.make_evaluator(
        evaluator=lambda s: s.count('1'), fitness_type=ugp4.fitness.Simple)

    # Create a list of operators with their aritiy
    operators = ugp4.Operators()
    # Add initialization operators
示例#7
0
                        action='store_const',
                        dest='verbose',
                        const=2,
                        help="log debug messages (same as -vv)")
    args = parser.parse_args()
    if args.verbose == 0:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.INFO)
    elif args.verbose == 1:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.VERBOSE)
    elif args.verbose > 1:
        ugp4.logging.DefaultLogger.setLevel(level=ugp4.logging.DEBUG)
        ugp4.logging.debug("Verbose level set to DEBUG")
    ugp4.logging.log_cpu(ugp4.logging.INFO, "Program started")

    # Define a parameter of type ugp4.parameter.Bitstring and length = 8
    word8 = ugp4.make_parameter(ugp4.parameter.Bitstring, len_=8)
    # Define a macro that contains a parameter of type ugp4.parameter.Bitstring
    word_macro = ugp4.Macro("{word8}", {'word8': word8})
    # Create a section containing a macro
    word_section = ugp4.make_section(word_macro, size=(1, 1), name='word_sec')

    # Create a constraints library
    library = ugp4.Constraints()
    # Define the sections in the library
    library['main'] = [word_macro]

    # Define the evaluator method and the fitness type
    def evaluator_function(data: str):
        count = data.count('1')
        return list(str(count))