コード例 #1
0
        /// <summary>
        /// Creates the W matrix that contains probabilities that user visits POI l when l' has been visited.
        /// </summary>
        private void createWMatrix()
        {
            alglib.sparsecreate(idLocMapper.Keys.Max() + 1, idLocMapper.Keys.Max() + 1, out this.W);
            foreach (int id1 in ratings.AllItems)
            {
                try{
                    if (nearestNeighbors[id1].Count < k)
                    {
                        Console.WriteLine("Unter 100!!");
                        throw new Exception();
                    }
                    foreach (int id2 in nearestNeighbors[id1])
                    {
                        if (id1 == id2)
                        {
                            throw new Exception();
                        }
                        alglib.sparseset(this.W, id1, id2, getDistanceProbability(id1, id2));
                    }
                }catch (Exception e) {
                }
            }
            alglib.sparseconverttocrs(W);

            W.normalize(ratings.AllItems, k);
        }