English 中文(简体)
这一行动的最佳数据结构
原标题:Best data structure for this operations

我试图找到一种更好的办法,即我目前的办法,来管理一个连续的Markov链的目前状态。 国家病媒使用的是(状态、可变性)乳房,其概率为浮动。

需要优化的算法中,有以下业务:

  • every iteration starts with a current state vector
  • computes the reachable states for every current one in vector and store all of them in a temporary list together with the probability of going there
  • for every element in this new list it calculates the new state vector by iterating over the possible transitions (mind that there can be many transitions which lead to the same state but found from different source states)

实际采用hashtables,这些表格作为国家的关键和价值。

因此,从根本上来说,为了建设新的病媒,每个过渡阶段的正常价值都是计算出来的,因此,病媒状态的恢复,增加了目前过渡的可能性,结果又被储存。

这种做法似乎迄今为止已经奏效,但我却试图应对在非常大的空间病媒(500k-1mil State)中起主导作用的系统,尽管仓促使储存和检索工作不断复杂化,但蒸汽实际上开始减缓许多工作。

例如,我们从一个拥有100克国家的病媒开始,对每一个国家来说,我们都是对可以接触的国家(通常为“......”);1 以便我们获得100k*(可以接触到的国家)的过渡清单。 然后,每一次过渡都是用来计算新的概率矢量。

不幸的是,我需要从整个可达到的清单中找到一种正常价值,而不实际计算下一个胎盘,但无论如何,正如我通过貌相看到的那样,这并不是算法的瓶颈。 每次过渡计算时都存在瓶颈。

用于计算现有病媒的过渡清单(pi):

HTable.fold (fun s p l ->
  if check s f2 then (0., s, p, [s, 1.0]) :: l
  else if not (check s f1) then (0., s, p, [s, 1.0]) :: l
  else
    let ts = P.rnext s in                         
    if List.length ts = 0 then (0., s, p, [s, 1.0]) :: l
    else
      let lm = List.fold_left (fun a (s,f) -> f +. a) 0. ts in
      (lm, s, p, ts) :: l) pi []

而这一职能是通过通过过渡名单来调整新的<代码>pi,并使所有这些功能正常化:

let update_pi s v = 
  try
    let t = HTable.find pi s in
    HTable.replace pi s (v +. t)
  with Not_found -> HTable.add pi s v
in
  HTable.clear pi;
  List.iter (fun (llm, s, p, ts) ->
    if llm = 0. then
      update_pi s p
    else begin
      List.iter (fun (ss, pp) -> 
        update_pi ss (p *. (pp /. lm))
      ) ts;
      if llm < lm then update_pi s (p *. (1. -. (llm /. lm)))
    end 
  ) u;

我应当找到一个最适合Im行动的数据结构,问题在于,根据目前的做法,我必须做一回事,为每个过渡阶段制定一套办法,但是,由于经常费用非常昂贵,因此,太多的反饥饿行动会杀害业绩。

最佳回答

不用按时段替换<代码>if List.length ts = 0,但我怀疑这将解决你的履约问题。

你的算法使病媒成倍增加一个矩阵,以获得新的病媒。 http://www.netlib.org/utk/papers/autoblock/node2.html” rel=“nofollow”>blocking 。 但在此,席上的代表性可能给你带来费用。 是否有可能一劳永逸地把所有国家都包括在内,然后使用阵列而不是仓s? 请注意,随着任意过渡,目的地国仍然不是地方性的,但可能是一种改进(如果仅仅因为进入一个阵列比接触一个洗衣机更直接)。

问题回答

暂无回答




相关问题
ocamlc, module compilation

I wrote an app in ocaml. It consist of several modules: Util (util.ml) Work1 (work1.ml) -- open Util Work2 (work2.ml) -- open Util, too Main (main.ml) -- open all of them. When i compile its, using ...

How can I simplify this ocaml pattern-matching code?

I m writing a simple little ocaml program that reads an algebraic statement in from a file, parses it into an AST using ocamllex/ocamlyacc, reduces it, and then prints it. The part where I m reducing ...

How can I create a type with multiple parameters in OCaml?

I m trying to create a type that has multiple type parameters. I know how to make a type with one parameter: type a foo = a * int But I need to have two parameters, so that I can parameterize the ...

Hashtable indexed on several fields

I m currently programming an OCaml module defining a type corresponding to a CPU register. The interface of this module is the following : (* * Defines a type which represents a R3000 register. *) ...

Extending an existing type in OCaml

I ve been doing some OCaml programming lately to learn the language and to get more acquainted with functional programming. Recently, I ve started to think that I d like to be able to extend an ...

Ocaml Syntax Error

What s wrong with this code? I can t figure it out: let parent (rules : grammar) (symbol1 : string) (symbol2 : string) : (SymbolSet.t) = try SymbolSet.singleton (getParent [symbol1; symbol2] ...

热门标签