示例#1
0
def iterativeEMDS(X0, N, d, C, b, max_it=10, print_out=False, **kwargs):
    """ Find the set of points from an edge kernel with geometric constraints, using iterative projection 
    """
    from pylocus.basics import mse, projection
    KE = kwargs.get('KE', None)
    KE_projected = KE.copy()
    d = len(X0)
    for i in range(max_it):
        # projection on constraints
        KE_projected, cost, __ = projection(KE_projected, C, b)
        rank = np.linalg.matrix_rank(KE_projected)

        # rank 2 decomposition
        Xhat_KE, Vhat_KE = superMDS(X0, N, d, KE=KE_projected)
        KE_projected = Vhat_KE.dot(Vhat_KE.T)

        error = mse(C.dot(KE_projected), b)

        if (print_out):
            print('cost={:2.2e},error={:2.2e}, rank={}'.format(
                cost, error, rank))
        if cost < 1e-20 and error < 1e-20 and rank == d:
            if (print_out):
                print('converged after {} iterations'.format(i))
            return Xhat_KE, Vhat_KE
    print('iterativeMDS did not converge!')
    return None, None
示例#2
0
    def test_projection(self):
        xhat, cost, constraints = projection(self.x, self.A, self.b)
        self.assertTrue(constraints <= 1e-20,
                        'Constraints not satisfied:{}'.format(constraints))

        xhat2, __, __ = projection(xhat, self.A, self.b)
        idempotent_error = mse(xhat, xhat2)
        self.assertTrue(idempotent_error < 1e-10, 'Projection not idempotent.')
示例#3
0
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np

from pylocus.point_set import PointSet
from pylocus.algorithms import reconstruct_srls
from pylocus.simulation import create_noisy_edm, create_mask, create_weights
from pylocus.basics import mse, rmse

points = PointSet(N=5, d=2)
points.set_points('random')
print("point to localize:", points.points[0, :])
print("anchors:", points.points[1:, :])

std = 0.1
edm_noisy = create_noisy_edm(points.edm, noise=std)

mask = create_mask(points.N, method='none')
weights = create_weights(points.N, method='one')
weights = np.multiply(mask, weights)

points_estimated = reconstruct_srls(edm_noisy, points.points, W=weights)
error = mse(points_estimated[0, :], points.points[0, :])

print("estimated point: {}, original point: {}, mse: {:2.2e}".format(
    points_estimated[0, :], points.points[0, :], error))