:- nodbgcomp.

:- lib(eplex_cplex).

:- [proptest_common].


setup_and_solve(inc, AB, N, Vars, OrderedPairs) :-
	setup_bounds(Vars, N),
	Vars = [X0|_],
	OptG=min(X0),
	lp_demon_setup(OptG,_C,[solution(no)],4,[new_constraint],H),
	setup_ordered(AB, OrderedPairs).
setup_and_solve(batch, AB, N, Vars, OrderedPairs) :-
	setup_bounds(Vars, N),
	Vars = [X0|_],
	OptG=min(X0),
	setup_ordered(AB, OrderedPairs),
	collect_lp_constraints_norm(NormCstr),
	lp_setup(NormCstr,OptG,[solution(no)],H),
	lp_solve(H,_C).


setup_bounds([], _N).
setup_bounds([X|Xs], N) :-
	X :: 0..N,
	setup_bounds(Xs, N).

setup_ordered(AB, OrderedPairs) :-
	(
	    foreach(Y1-Y2,OrderedPairs),
	    param(AB)
	do
	    Y2 $>= Y1+AB
	).
