Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Julia module memory and global variable issue #95

Open
ShubhamGoel96 opened this issue Sep 4, 2023 · 0 comments
Open

Julia module memory and global variable issue #95

ShubhamGoel96 opened this issue Sep 4, 2023 · 0 comments

Comments

@ShubhamGoel96
Copy link

How to add memory feature in this reserve calculation or add a global variable type in a Julia module structure-

Code-
function reserves_calc(projection::Projection)
max_t = policy_term(projection)* 12
annual_disc_rate = 0.08
#monthly_disc_rate = maximum(BasicTerm_ME.disc_rate(t,projection)) #0.0064

    res_l = zeros(max_t + 1)  # Preallocate array for inc_in_res

    for t in max_t:-1:0
        if t == max_t
            res_l[t+1] = 0#BasicTerm_ME.reserves(t, projection)
        elseif t > proj_len(projection)[] 
            res_l[t+1] = 0.0
        else
            res_l[t+1] = max(-10000000,(val_net_cashflow(t+1, projection) .+ res_l[t+2]) / (1 .+ maximum(disc_rate(t,projection))))#BasicTerm_ME.reserves(t, projection) #- BasicTerm_ME.reserves((t-1), projection)
        end
    end
    return res_l
end


function reserves(t,projection)#, projection::Projection)
    x = reserves_calc(projection)
    return x[t]
end    

I want to use the results of res_l array in reserves function without running reserves_calc function each time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant