/*
Volsay problem in Picat.
From OPL model volsay.mod
"""
Consider a Belgian company Volsay, which specializes in producing ammoniac gas
(NH3) and ammonium chloride (NH4Cl). Volsay has at its disposal 50 units of
nitrogen (N), 180 units of hydrogen (H), and 40 units of chlorine (Cl). The company
makes a profit of 40 Euros for each sale of an ammoniac gas unit and 50 Euros
for each sale of an ammonium chloride unit. Volsay would like a production plan
maximizing its profits given its available stocks.
"""
Model created by Hakan Kjellerstrand, hakank@gmail.com
See also my Picat page: http://www.hakank.org/picat/
*/
import cp.
% import mip.
scalar_product(A, X, Product) =>
Product #= sum([S : I in 1..A.length, S #= A[I]*X[I]]).
% scalar product with relation
scalar_product(A, X, Rel, Product) =>
scalar_product(A, X, P),
call(Rel,P,Product).
main => go.
go =>
Products = [Gas, Chloride],
Products :: 0..100000,
Profits = [40,50],
Hydrogen = [3,4],
MaxHydrogen = 180,
MaxUnits = 50,
scalar_product(Products,Hydrogen, #=<, MaxHydrogen),
scalar_product(Products, Profits,MaxVal),
sum(Products) #=< MaxUnits,
solve([$max(MaxVal)],Products),
writeln(gas=Gas),
writeln(chloride=Chloride),
writeln(max_val=MaxVal),
nl.