/usr/share/swi-prolog/pack/clpBNR/prolog/clpBNR_toolkit.pl
All Application Manual Name SummaryHelp

  • clpBNR
    • prolog
      • clpBNR.pl -- clpBNR: Constraint Logic Programming over Continuous Domain of Reals
      • clpBNR_toolkit.pl -- clpBNR_toolkit: Toolkit of various utilities used for solving problems with clpBNR
        • iterate_until/3
        • mid_split_one/1
        • mid_split/1
        • cf_contractor/2
        • cf_solve/1
        • cf_solve/2
        • taylor_contractor/2
        • taylor_merged_contractor/2
        • lin_minimum/3
        • lin_maximum/3
        • lin_minimize/3
        • lin_maximize/3
        • local_minima/1
        • local_maxima/1
        • local_minima/2
        • local_maxima/2
 iterate_until(+Count:integer, Test, Goal) is nondet
Succeeds when Goal succeeds; otherwise fails. Goal will be called recursively up to Count times as long as Test succeeds Example using this predicate for simple labelling using Test small/2 and Goal midsplit/1 :
?- X::real(-1,1),iterate_until(10,small(X,0),mid_split(X)),format("X = ~w\n",X),fail;true.
X = _6288{real(-1,-1r2)}
X = _6288{real(-1r2,0)}
X = _6288{real(0,1r2)}
X = _6288{real(1r2,1)}
true.

The specific intended use case is to provide an iterator for meta-contractors such as the centre-form contractor such as midsplit/1 (example above) or as constructed by taylor_contractor/2 as in:

?- X::real,taylor_contractor({X**4-4*X**3+4*X**2-4*X+3==0},T),
iterate_until(50,small(X),(T,mid_split_one([X]))),format("X = ~w\n",X),fail;true.
X = _150{real(0.999999999926943,1.00000000007306)}
X = _150{real(2.999999999484828,3.0000000005152105)}
true.

(Aside: For some problems, solving with Taylor contractors can be a faster and more precise alternative to clpBNR:solve/1.)