Design and operations optimization of membrane-based flexible carbon capture