Let A ⊆ N n be a finite set, and K ⊆ R n be a compact semialgebraic set. An A-truncated multisequence (A-tms) is a vector y = (yα) indexed by elements in A. The A-truncated K-moment problem (A-TKMP) concerns whether or not a given A-tms y admits a K-measure µ, i.e., µ is a nonnegative Borel measure supported in K such that yα = K x α dµ for all α ∈ A. This paper proposes a numerical algorithm for solving A-TKMPs. It aims at finding a flat extension of y by solving a hierarchy of semidefinite relaxations {(SDR) k } ∞ k=1 for a moment optimization problem, whose objective R is generated in a certain randomized way. If y admits no K-measures and R[x] A is K-full (there exists p = α∈A pαx α that is positive on K), then (SDR) k is infeasible for all k big enough, which gives a certificate for the nonexistence of representing measures. If y admits a K-measure, then for almost all generated R, this algorithm has the following properties: i) we can asymptotically get a flat extension of y by solving the hierarchy {(SDR) k } ∞ k=1 ; ii) under a general condition that is almost sufficient and necessary, we can get a flat extension of y by solving (SDR) k for some k; iii) the obtained flat extensions admit a ratomic K-measure with r ≤ |A|. The decomposition problems for completely positive matrices and sums of even powers of real linear forms, and the standard truncated K-moment problems, are special cases of A-TKMPs. They can be solved numerically by this algorithm. R A (K) := {y ∈ R A : meas(y, K) = ∅}. 1991 Mathematics Subject Classification. 44A60, 47A57, 90C22, 90C90. Key words and phrases. A-truncated multisequence, A-truncated K-moment problem, completely positive matrices, flat extension, moment matrix, localizing matrix, representing measure, semidefinite program, sums of even powers. 1 For each J ⊆ {1, . . . , m 2 + 1}, denoteThe set of critical points of (A.1) with the active set J is contained in V J , which is called a critical variety of (A.1). We show that if the coefficients of f hom , h hom , g hom J satisfy some discriminantal inequalities, then V J is finite. We refer to [33, Section 3]) for the definition of discriminants ∆. Proposition A.1. Let f, h i (i ∈ [m 1 ]), g j (j ∈ [m 2 + 1]) ∈ R[x], and V J be defined as above. For any J ⊆ [m 2 + 1], if ∆(f hom , h hom , g hom J ) = 0, ∆(h hom , g hom J ) = 0, (A.3) rank Jac(f hom , h hom , g hom J )| x ≤ m 1 + |J|, h hom (x) = g hom J (x) = 0. Since ∆(h hom , g hom J ) = 0, rank Jac(h hom , g hom J )| x = m 1 + |J| for all 0 = x ∈ V C (h hom , g hom J ). The rank condition in (A.3) implies that f hom (v) = 0 (cf. [33, Section 3]). Hence, v is a nonzero singular solution to f hom (x) = h hom (x) = g hom J (x) = 0, which contradicts ∆(f hom , h hom , g hom J ) = 0 (cf. [33]). So, V J must be finite.