<commit_before>import argparse
from xml.etree import ElementTree

from xml_parser_helper import load_xml_model
import spl_claferanalyzer
import math

_namespaces = {'c1': 'http://gsd.uwaterloo.ca/clafer', 'xsi': 'http://www.w3.org/2001/XMLSchema-instance'}


def execute_main():

    parser = argparse.ArgumentParser(description='Reads an XML file of a feature tree created in for a Software Product and generates the required alloy partial instance block to speed up analysis  for this model.')
        
    parser.add_argument('clafer_feature_model_xml_filename', metavar='F', type=str, nargs=1,
                       help='XML file of Software Product Line feature model in clafer to open.')
        
    args = parser.parse_args()
        
    xml_model = load_xml_model(args.clafer_feature_model_xml_filename[0])

    SPL = spl_claferanalyzer.get_top_level_SPL_model(xml_model)
    
    print "inst partial_speedup {"
    print "    1"
    
    # Compute the maximum bit width for integers, first compute the highest possible 
    max_integer = 0
    for clafer_features in SPL.findall(".//c1:Declaration[@xsi:type='cl:IClafer']", namespaces=_namespaces):
        if spl_claferanalyzer.get_clafer_Id(clafer_features)!='total_footprint':
            max_integer = max_integer + max(int(spl_claferanalyzer.get_footprint(clafer_features)), 0)

    # Compute Bitwidth, we have to add 1 to max_integer due to "0", and 1 to the total due to negative numbers.
    max_bitwidth = math.ceil(math.log(max_integer+1, 2)) + 1 
    
    
    print "    , %s  int" % max(4, int(max_bitwidth))
    
    # Print partial instances of individual features, children of IMeasurable.
    for clafer_features in SPL.findall(".//c1:Declaration[@xsi:type='cl:IClafer']", namespaces=_namespaces):
        if spl_claferanalyzer.get_clafer_Id(clafer_features)!='total_footprint':
            print "   , %s in partial_%s" %  (spl_claferanalyzer.get_clafer_UniqueId(clafer_features), spl_claferanalyzer.get_clafer_UniqueId(clafer_features) )    
    footprint_clafer = [x for x in xml_model.findall(".//c1:Declaration[@xsi:type='cl:IClafer']", namespaces=_namespaces) if spl_claferanalyzer.get_clafer_Id(x) =='footprint'][0]
    
    
    # Print footprint for specific Element.
    print "    ,  %s in " % spl_claferanalyzer.get_clafer_UniqueId(footprint_clafer), 
    list_of_IMeasurableChildren = []
    for clafer_features in SPL.findall(".//c1:Declaration[@xsi:type='cl:IClafer']", namespaces=_namespaces):
        if spl_claferanalyzer.get_clafer_Id(clafer_features)!='total_footprint':
            list_of_IMeasurableChildren.append("footprint_for_%s_of_%s" % (spl_claferanalyzer.get_clafer_UniqueId(clafer_features), spl_claferanalyzer.get_footprint(clafer_features).replace('-', 'minus') )  )
    print ' + '.join(list_of_IMeasurableChildren)

    
    # Print Feature  to specific  footprint   relation.
    print '    , r_%s in ' % spl_claferanalyzer.get_clafer_UniqueId(footprint_clafer), 
    print ' + '.join([ "partial_%s->footprint_for_%s_of_%s" % (spl_claferanalyzer.get_clafer_UniqueId(clafer_features), spl_claferanalyzer.get_clafer_UniqueId(clafer_features) , spl_claferanalyzer.get_footprint(clafer_features).replace('-', 'minus') )   \
                 for clafer_features in \
                 [x for x in SPL.findall(".//c1:Declaration[@xsi:type='cl:IClafer']", namespaces=_namespaces) if spl_claferanalyzer.get_clafer_Id(x)!='total_footprint']])

    # Print Footprint  to specific  number   relation.
    print '    , %s_ref in ' % spl_claferanalyzer.get_clafer_UniqueId(footprint_clafer), 
    print ' + '.join([ "footprint_for_%s_of_%s-> %s" % ( spl_claferanalyzer.get_clafer_UniqueId(clafer_features) , spl_claferanalyzer.get_footprint(clafer_features).replace('-', 'minus'),  spl_claferanalyzer.get_footprint(clafer_features) )   \
                 for clafer_features in \
                 [x for x in SPL.findall(".//c1:Declaration[@xsi:type='cl:IClafer']", namespaces=_namespaces) if spl_claferanalyzer.get_clafer_Id(x)!='total_footprint']])

    
    print "}"

    print "run show for partial_speedup"

execute_main()<commit_msg>Added goals to clafer configurator<commit_after>import argparse
from xml.etree import ElementTree

from xml_parser_helper import load_xml_model
import spl_claferanalyzer
import math

_namespaces = {'c1': 'http://gsd.uwaterloo.ca/clafer', 'xsi': 'http://www.w3.org/2001/XMLSchema-instance'}


def execute_main():

    parser = argparse.ArgumentParser(description='Reads an XML file of a feature tree created in for a Software Product and generates the required alloy partial instance block to speed up analysis  for this model.')
        
    parser.add_argument('clafer_feature_model_xml_filename', metavar='F', type=str, nargs=1,
                       help='XML file of Software Product Line feature model in clafer to open.')
        
    args = parser.parse_args()
        
    xml_model = load_xml_model(args.clafer_feature_model_xml_filename[0])

    SPL = spl_claferanalyzer.get_top_level_SPL_model(xml_model)
    
    print "inst partial_speedup {"
    print "    1"
    
    # Compute the maximum bit width for integers, first compute the highest possible 
    max_integer = 0
    for clafer_features in SPL.findall(".//c1:Declaration[@xsi:type='cl:IClafer']", namespaces=_namespaces):
        if spl_claferanalyzer.get_clafer_Id(clafer_features)!='total_footprint':
            max_integer = max_integer + max(int(spl_claferanalyzer.get_footprint(clafer_features)), 0)

    # Compute Bitwidth, we have to add 1 to max_integer due to "0", and 1 to the total due to negative numbers.
    max_bitwidth = math.ceil(math.log(max_integer+1, 2)) + 1 
    
    
    print "    , %s  int" % max(4, int(max_bitwidth))
    
    # Print partial instances of individual features, children of IMeasurable.
    for clafer_features in SPL.findall(".//c1:Declaration[@xsi:type='cl:IClafer']", namespaces=_namespaces):
        if spl_claferanalyzer.get_clafer_Id(clafer_features)!='total_footprint':
            print "   , %s in partial_%s" %  (spl_claferanalyzer.get_clafer_UniqueId(clafer_features), spl_claferanalyzer.get_clafer_UniqueId(clafer_features) )    
    footprint_clafer = [x for x in xml_model.findall(".//c1:Declaration[@xsi:type='cl:IClafer']", namespaces=_namespaces) if spl_claferanalyzer.get_clafer_Id(x) =='footprint'][0]
    
    
    # Print footprint for specific Element.
    print "    ,  %s in " % spl_claferanalyzer.get_clafer_UniqueId(footprint_clafer), 
    list_of_IMeasurableChildren = []
    for clafer_features in SPL.findall(".//c1:Declaration[@xsi:type='cl:IClafer']", namespaces=_namespaces):
        if spl_claferanalyzer.get_clafer_Id(clafer_features)!='total_footprint':
            list_of_IMeasurableChildren.append("footprint_for_%s_of_%s" % (spl_claferanalyzer.get_clafer_UniqueId(clafer_features), spl_claferanalyzer.get_footprint(clafer_features).replace('-', 'minus') )  )
    print ' + '.join(list_of_IMeasurableChildren)

    
    # Print Feature  to specific  footprint   relation.
    print '    , r_%s in ' % spl_claferanalyzer.get_clafer_UniqueId(footprint_clafer), 
    print ' + '.join([ "partial_%s->footprint_for_%s_of_%s" % (spl_claferanalyzer.get_clafer_UniqueId(clafer_features), spl_claferanalyzer.get_clafer_UniqueId(clafer_features) , spl_claferanalyzer.get_footprint(clafer_features).replace('-', 'minus') )   \
                 for clafer_features in \
                 [x for x in SPL.findall(".//c1:Declaration[@xsi:type='cl:IClafer']", namespaces=_namespaces) if spl_claferanalyzer.get_clafer_Id(x)!='total_footprint']])

    # Print Footprint  to specific  number   relation.
    print '    , %s_ref in ' % spl_claferanalyzer.get_clafer_UniqueId(footprint_clafer), 
    print ' + '.join([ "footprint_for_%s_of_%s-> %s" % ( spl_claferanalyzer.get_clafer_UniqueId(clafer_features) , spl_claferanalyzer.get_footprint(clafer_features).replace('-', 'minus'),  spl_claferanalyzer.get_footprint(clafer_features) )   \
                 for clafer_features in \
                 [x for x in SPL.findall(".//c1:Declaration[@xsi:type='cl:IClafer']", namespaces=_namespaces) if spl_claferanalyzer.get_clafer_Id(x)!='total_footprint']])

    
    print "}"

    print "run show for partial_speedup optimize o_global"

execute_main()
{'fraction_non_alphanumeric': 0.11125795987023909, 'fraction_numerical': 0.0060074492370539466, 'mean_word_length': 4.218808777429467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 18}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7658402', 'n_tokens_mistral': 2974, 'n_tokens_neox': 2900, 'n_words': 509}