This is somewhat related to my other post (Deleting containerized constraints) but here, I want to see if there is a way to formulate my constraint differently.
Following advice in this thread, I put all my variable and constraint creation statements inside individual functions. This improved model generation time significantly. However, the following constraint is taking 30 seconds to formulate with 369 nodes and 548 branches:
function gen_q_baseflow(v_baseflow,v_net_injection,ptdf_b_n) @constraint(m, q_baseflow[b in branch(), (t,s) in T_S], + v_baseflow[b,t,s] == + sum( ptdf_b_n[b,n] * v_net_injection[n,t,s] for n in injection_nodes if abs(ptdf_b_n[b,n]) > tx_pdtf_tolerance(settings=:TRANSMISSION)) ) end
What can I do to improve the creation time of this?