Hello i have problem like that:
We have coins: 1 cent, 2 cents, 5 cents, 10 cents, 20 cents, 50 cents, 1 dolar and 2 dolars. How many ways can you get 2 dolars using any number of coins?
And my solution for this problem is:
set COINS;
param total, integer, >= 0;
param coin_value{COINS}, >= 0;
var dp{0..total}, integer, >= 0;
s.t. initial: dp[0] = 1;
s.t. dp_fill {j in 1..total, c in COINS: j >= coin_value[c]}:
dp[j] = dp[j] + dp[j – coin_value[c]];
maximize ways: dp[total];
solve;
display dp[total];
data;
param total := 200; # Total amount we want to make (200 cents)
set COINS := 1 2 5 10 20 50 100 200;
param coin_value :=
1 1
2 2
5 5
10 10
20 20
50 50
100 100
200 200;
end;
every time i have anwser like this:
GLPSOL: GLPK LP/MIP Solver, v4.57
Parameter(s) specified in the command line:
–math input_file
Reading model section from input_file…
Reading data section from input_file…
45 lines were read
Generating initial…
Generating dp_fill…
Generating ways…
Model has been successfully generated
GLPK Integer Optimizer, v4.57
1222 rows, 201 columns, 1222 non-zeros
201 integer variables, none of which are binary
Preprocessing…
PROBLEM HAS NO PRIMAL FEASIBLE SOLUTION
Time used: 0.0 secs
Memory used: 0.6 Mb (634559 bytes)
Please help me guys!