Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

26
LINES

< > BotCompany Repo | #1032029 // psCollect - collect output of probabilistic actions

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4862L/28K).

// This version is good when the probabilities returned
// are monotonically decreasing. To look for the best results
// when probabilities tend to increase over time, use
// PSCollectMostProbable.

static <A> IVF1<A> psCollect(IProbabilisticScheduler ps, Cl<WithProbability<A>> out) {
  ret a -> {
    if (out != null)
      out.add(withPreciseProbability(ps.currentProbability(), a));
  };
}

svoid <A> psCollect(ProbabilisticScheduler ps,
  Cl<WithProbability<A>> results_out,
  int maxResults,
  IVF1<IVF1<A>> action) {
  action.get(psCollect(ps, results_out));
  stepUntil(ps, () -> l(results_out) >= 10);
}

static <A> L<WithProbability<A>> psCollect(int maxResults, IVF2<IProbabilisticScheduler, IVF1<A>> action) {
  new ProbabilisticScheduler ps;
  new L<WithProbability<A>> results;
  psCollect(ps, results, maxResults, out -> action.get(ps, out));
  ret results;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032029
Snippet name: psCollect - collect output of probabilistic actions
Eternal ID of this version: #1032029/8
Text MD5: 10625de896e36b2c476aee43fcc121a8
Transpilation MD5: ef0b3a2abdfb68d9ea92d103a5d5ee8a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-11 08:39:25
Source code size: 899 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 168 / 245
Version history: 7 change(s)
Referenced in: [show references]