def run(fns_in, corner, run_corner, sub_json=None, bounds_csv=None, dedup=True, massage=False, outfn=None, verbose=False, **kwargs): print('Loading data') Ads, b = loadc_Ads_b(fns_in, corner, ico=True) # Remove duplicate rows # is this necessary? # maybe better to just add them into the matrix directly if dedup: oldn = len(Ads) iold = instances(Ads) Ads, b = simplify_rows(Ads, b, corner=corner) print('Simplify %u => %u rows' % (oldn, len(Ads))) print('Simplify %u => %u instances' % (iold, instances(Ads))) if sub_json: print('Sub: %u rows' % len(Ads)) iold = instances(Ads) names_old = index_names(Ads) run_sub_json(Ads, sub_json, verbose=verbose) names = index_names(Ads) print("Sub: %u => %u names" % (len(names_old), len(names))) print('Sub: %u => %u instances' % (iold, instances(Ads))) else: names = index_names(Ads) ''' Substitution .csv Special .csv containing one variable per line Used primarily for multiple optimization passes, such as different algorithms or additional constraints ''' if bounds_csv: Ads2, b2 = loadc_Ads_b([bounds_csv], corner, ico=True) bounds = Ads2bounds(Ads2, b2) assert len(bounds), 'Failed to load bounds' rows_old = len(Ads) Ads, b = filter_bounds(Ads, b, bounds, corner) print('Filter bounds: %s => %s + %s rows' % (rows_old, len(Ads), len(Ads2))) Ads = Ads + Ads2 b = b + b2 assert len(Ads) or allow_zero_eqns() assert len(Ads) == len(b), 'Ads, b length mismatch' if verbose: print print_eqns(Ads, b, verbose=verbose) #print #col_dist(A_ubd, 'final', names) if massage: try: Ads, b = massage_equations(Ads, b, corner=corner) except SimplifiedToZero: if not allow_zero_eqns(): raise print('WARNING: simplified to zero equations') Ads = [] b = [] print('Converting to numpy...') names, Anp = A_ds2np(Ads) run_corner(Anp, np.asarray(b), names, corner, outfn=outfn, verbose=verbose, **kwargs)
def debug(what): check_cols() if 1 or verbose: print('') print_eqns(Ads, b, verbose=verbose, label=what, lim=20) col_dist(Ads, what)
def debug(what): if verbose: print('') print_eqns(Ads, b, verbose=verbose, label=what, lim=20) col_dist(Ads, what) check_feasible_d(Ads, b)