refactor ModelState type

now abstract with 1d and 2d concrete types to allow dispatch based on dimension
it may make sense to merge 2d into a general nD type in the future

also make model params an attribute of model state because (1) model params
aren't necessarily fixed and so should be considered stateful and (2) it reduced
the number of things functions need to explicitly pass around