go:-
Vars=[X1,X2,X3],
lp_domain(X1,0,40), % 0 =< X1 =< 40
-X1+X2+X3 $=< 20, % constraints
X1-3*X2+X3 $=< 30,
Profit=X1+2*X2+3*X3, % objective function
lp_solve(Vars,max(Profit)), % call the LP solver
format("sol(~w,~f)~n",[Vars,Profit]).
Three new operators are introduced: $=, $>=, and $=< for expressing equality and disequality constraints.13.4 The call lp_solve(Vars,max(Profit)) calls the LP solver to find a valuation for Vars that maximizes Profit and satisfies all the constraints on the variables. A MIP problem is similar to a LP problem except that some variables are required to be integers. The built-in lp_integers(Vars) is provided to declare integer variables. For MIP problems, the same built-in lp_solve/2 is used to call the MIP solver. The interface decides which solver to call based on whether or not there are integer variables. More examples can be found in the directory examples/lp.
The following built-ins are provided to communicate with LP/MIP packages:
Exp1 R Exp2 where R is $=, $>=, or $=<: An equality or disequality constraint, where Exp1 and Exp2 are two arithmetic expressions made up of integers, floats, variables, and the following arithmetic functions: + (addition), - (subtraction), * (multiplication), / (division), and sum. The expression sum(List) denotes the sum of the elements in List.
Neng-Fa Zhou 2012-01-03