// File: bonetblai[P]mdp-engine/ctp3/../engine/value_iteration.h
// Function: Algorithm::value_iteration_t<state_t>::solve(state_t const&, Problem::hash_t<state_t>&) const
virtual void solve(const T &s, Problem::hash_t<T> &hash) const {
        reset_stats(hash);
        Heuristic::wrapper_t<T> eval_function(heuristic_);
        hash.set_eval_function(&eval_function);

        state_space_t<T> state_space(problem_);
        state_space.generate_space(s, hash);

#ifdef DEBUG
        std::cout << "debug: value-iteration(): state-space-size = " << hash.size() << std::endl;
#endif

        size_t iters = 0;
        float residual = 1 + epsilon_;
        while( residual > epsilon_ ) {
            if( iters > max_number_iterations_ ) break;
            residual = 0;
            for( hash_iterator hi = hash.begin(); hi != hash.end(); ++hi ) {
                float hv = hi->second->value();
                std::pair<Problem::action_t, float> p = hash.best_q_value(hi->first);
                float res = (float)fabs(p.second - hv);
                residual = Utils::max(residual, res);
                hi->second->update(p.second);
                hash.inc_updates();

#ifdef DEBUG
                if( res > epsilon_ ) {
                    std::cout << "debug: value-iteration(): value for " << hi->first
                              << " changed from " << hv
                              << " to " << p.second
                              << std::endl;
                }
#endif
            }
            ++iters;

#ifdef DEBUG
            std::cout << "debug: value-iteration(): residual=" << residual << std::endl;
#endif
        }
        hash.set_eval_function(0);
    }

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movq %rdx, 0x90(%rsp)
movq 0xa0(%rsp), %rdi
movq %rdi, 0x30(%rsp)
movq 0x90(%rsp), %rsi
movq (%rdi), %rax
movq 0x30(%rax), %rax
callq *%rax
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x80(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x20c30
movq 0x28(%rsp), %rsi
movq 0x90(%rsp), %rdi
callq 0x20c70
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x78(%rsp), %rdi
callq 0x31890
jmp 0x315ef
movq 0x98(%rsp), %rsi
movq 0x90(%rsp), %rdx
leaq 0x78(%rsp), %rdi
callq 0x318b0
jmp 0x3160b
movq 0x30(%rsp), %rax
movq $0x0, 0x60(%rsp)
movss 0x2b9e3(%rip), %xmm0    # 0x5d004
addss 0x1c(%rax), %xmm0
movss %xmm0, 0x5c(%rsp)
movq 0x30(%rsp), %rax
movss 0x5c(%rsp), %xmm0
ucomiss 0x1c(%rax), %xmm0
jbe 0x31791
movq 0x30(%rsp), %rcx
movq 0x60(%rsp), %rax
movl 0x20(%rcx), %ecx
cmpq %rcx, %rax
jbe 0x31678
jmp 0x31791
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x21630
jmp 0x317b7
movl $0x0, 0x5c(%rsp)
movq 0x90(%rsp), %rdi
callq 0x31cb0
movq %rax, 0x20(%rsp)
jmp 0x31694
movq 0x20(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x90(%rsp), %rdi
callq 0x217e0
movq %rax, 0x48(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x2c3d0
testb $0x1, %al
jne 0x316c8
jmp 0x3177e
leaq 0x50(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x31ce0
movq 0x70(%rax), %rdi
callq 0x22fc0
movq 0x8(%rsp), %rdi
movss %xmm0, 0x44(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
callq 0x31ce0
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x22eb0
movq %rax, 0x18(%rsp)
jmp 0x31711
movq 0x18(%rsp), %rax
movq %rax, 0x3c(%rsp)
movss 0x40(%rsp), %xmm0
subss 0x44(%rsp), %xmm0
callq 0x22fa0
movss %xmm0, 0x38(%rsp)
movss 0x5c(%rsp), %xmm0
movss 0x38(%rsp), %xmm1
callq 0x25590
movss %xmm0, 0x5c(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x31ce0
movq 0x70(%rax), %rdi
movss 0x40(%rsp), %xmm0
callq 0x22fd0
movq 0x90(%rsp), %rdi
callq 0x22ff0
leaq 0x50(%rsp), %rdi
callq 0x31d00
jmp 0x3169e
movq 0x60(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
jmp 0x3162c
movq 0x90(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x20c70
leaq 0x80(%rsp), %rdi
callq 0x21630
addq $0xa8, %rsp
retq
movq 0x70(%rsp), %rdi
callq 0x6520
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)