Add arbitrary optimization direction support to TRW