### Speeding up constraint creation during compilation

Posted:

**Tue Jun 04, 2019 7:18 pm**Hi everyone

So I have a constraint like

The parameter gen_minup(non_vre) is in the range of 2-24. Sets z and non_vre have 20 and 3 elements respectively.

The constraint is quite computationally expensive time wise during the compile step of my model. I'm guessing this is because h contains at a minimum 8760 elements. Have I missed anything in terms of set ordering in the variable that could speed this up? Or indeed anything else that could speed this up?

I note that in the full version of my model I already limit the creation of the constraint to the smallest number of z and non_vre combinations I can using $ subset.

Thanks!

So I have a constraint like

Code: Select all

```
eq_uc_gen_minup(h,z,non_vre) .. sum(h_alias$(ord(h_alias) ge (ord(h) - gen_minup(non_vre)+1) and ord(h_alias) lt ord(h)),var_up_units(h_alias,z,non_vre)) =L= var_com_units(h,z,non_vre)
with
alias(h,h_alias)
```

The constraint is quite computationally expensive time wise during the compile step of my model. I'm guessing this is because h contains at a minimum 8760 elements. Have I missed anything in terms of set ordering in the variable that could speed this up? Or indeed anything else that could speed this up?

I note that in the full version of my model I already limit the creation of the constraint to the smallest number of z and non_vre combinations I can using $ subset.

Thanks!