I'm trying to run this code but I get this error anytime I use this query: gp174(P, S).
ERROR: >=/2: Arguments are not sufficiently instantiated.
and this is my code:
call_option(B,S,C,E,P) :-
0 =< S,
S =< E / 100,
P = -C * B.
call_option(B,S,C,E,P) :-
S >= E / 100,
P = (100 * S - E - C) * B.
gp173(P) :-
call_option(1, 7, 200, 300, P).
% butterfly strike p174.
butterfly(S, H) :-
H = P1 + 2*P2 + P3,
Buy = 1, Sell = -1,
call_option(Buy, S, 100, 500, P1),
call_option(Sell, S, 200, 300, P2),
call_option(Buy, S, 400, 100, P3).
% goal for butterfly strike
gp174(P,S) :-
P >= 0,
butterfly(S,P).
What should I do?
Where should I load my clpr library?
I tried to modify using the documented library:
:- [library(clpr)].
call_option(B,S,C,E,P) :-
{0 =< S},
{S =< E / 100},
{P = -C * B}.
call_option(B,S,C,E,P) :-
{S >= E / 100},
{P = (100 * S - E - C) * B}.
gp173(P) :-
call_option(1, 7, 200, 300, P).
% butterfly strike p174.
butterfly(S, H) :-
{H = P1 + 2*P2 + P3,
Buy = 1, Sell = -1},
call_option(Buy, S, 100, 500, P1),
call_option(Sell, S, 200, 300, P2),
call_option(Buy, S, 400, 100, P3).
% goal for butterfly strike
gp174(P,S) :-
{P >= 0},
butterfly(S,P).
and this is the result:
?- gp174(P,S).
{S=2.0+0.01*P, P=<100.0, _G56405= -300.0+P, P>=0.0} ;
{S=4.0-0.01*P, P=<100.0, _G59475= -100.0-P, _G59488=100.0+P, P>=0.0} ;
false.
HTH