Esempio n. 1
0
 def lp_constraint_model_build_model(self, S):
     years = S.numyr
     taxbins = len(self.taxinfo.taxtable)
     cgbins = len(self.taxinfo.capgainstable)
     accounts = len(S.accounttable)
     verbose = False
     disallowdeposits = False
     vindx = v.vector_var_index(years, taxbins, cgbins, accounts, S.accmap)
     lp = lpclass.lp_constraint_model(S, vindx, self.taxinfo.taxtable,
                                      self.taxinfo.capgainstable,
                                      self.taxinfo.penalty,
                                      self.taxinfo.stded,
                                      self.taxinfo.SS_taxable,
                                      verbose, 
                                      disallowdeposits)
     c, A, b = lp.build_model()
     return vindx, lp, c, A, b
Esempio n. 2
0
    def test_input_through_solver_joint_first_year_spinding(self):
        toml_file_name = 't.toml'
        skipfilewrite = True
        tf = working_toml_file(toml_file_name, skipfilewrite)
        dict =tf.toml_dict()
        dict['retirement_type'] = 'joint'
        tf.toml_dict(dict) # update tf.tomls
        tf.write_working_toml_file(tf.tomls)
        taxinfo = tif.taxinfo()
        S = tomldata.Data(taxinfo)
        S.load_toml_file(toml_file_name)
        S.process_toml_info()

        years = S.numyr
        taxbins = len(taxinfo.taxtable)
        cgbins = len(taxinfo.capgainstable)
        accounts = len(S.accounttable)
        verbose = False
        disallowdeposits = False
        vindx = v.vector_var_index(years, taxbins, cgbins, accounts, S.accmap)
        lp = lpclass.lp_constraint_model(S, vindx, taxinfo.taxtable,
                                        taxinfo.capgainstable,
                                        taxinfo.penalty, 
                                        taxinfo.stded,
                                        taxinfo.SS_taxable, 
                                        verbose, 
                                        disallowdeposits)
        c, A, b = lp.build_model()

        res = scipy.optimize.linprog(c, A_ub=A, b_ub=b,
                                     options={"disp": verbose,
                                              #"bland": True,
                                              "tol": 1.0e-7,
                                              "maxiter": 3000})
        self.assertTrue(res.success, msg='res.success indicates solver failed')
        # If we get this far test the output
        year = 0
        verifiedSolverResult = 220896.0970
        latestSolverResult = res.x[vindx.s(year)]
        self.assertEqual(round(latestSolverResult,3), round(verifiedSolverResult,3), msg='Verified solver result is ${:0_.3f} but here we got ${:0_.3f}'.format(verifiedSolverResult, latestSolverResult))
Esempio n. 3
0
    vid = [
        years, taxbins, cgbins, S.accmap["IRA"], S.accmap["roth"],
        S.accmap["aftertax"]
    ]

    #print("Is modelDumpTable Set?")
    if args.modeldumptable != '':
        #print("ModelDumpTable set")
        print(args.modeldumptable)

    if precheck_consistancy():

        if args.modelloadtable == '':
            model = lp.lp_constraint_model(S, vindx, taxinfo.taxtable,
                                           taxinfo.capgainstable,
                                           taxinfo.penalty, taxinfo.stded,
                                           taxinfo.SS_taxable, args.verbose,
                                           args.notdrarothradeposits)
            c, A, b, notes = model.build_model()
            """
            if args.modeldumptable != '':
                #modelio.dumpModel(c, A, b)
                modelio.binDumpModel(c, A, b, None, args.modeldumptable)
            """
        else:
            print("Loadfile: ", args.modelloadtable)
            c, A, b, vid = modelio.binLoadModel(args.modelloadtable)
            note = None
        #verifyInputs( c , A , b )
        if args.timesimplex:
            t = time.process_time()