write constraints
start caching extarray, not finished