Exemple #1
0
# -*- coding: utf-8 -*-

from xlrd import open_workbook
import numpy as np
import time
import random

from solution_class import Solution
from reading import reading
from construction import construction
from lns import lns

for ins in range(14, 15):
    N, M, P, c, a, b = reading(ins)

    cputime = time.time()

    # Initial solution
    F = construction(N, M, P, c, a, b)

    # Improvement
    F = lns(N, M, P, c, a, b, F, cputime)

    print(F.Z)
    print("%1.2f \t" % (time.time() - cputime))
Exemple #2
0
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 26 14:16:39 2020

@author: jrivera6
"""

# -*- coding: utf-8 -*-

from xlrd import open_workbook
import numpy as np
import time
import random

from reading import reading
from construction import construction
from construction import construction_red

ins = 'scpe5'
#ins = 'scpnrh5'

n, m, c, a, ni, nj, listi, listj, K, w = reading(ins)

S, assigned, covered, Z, na = construction(n, m, c, a, ni, nj, listi, listj)

S, assigned, covered, Z, na = construction_red(n, m, c, a, ni, nj, listi,
                                               listj, K, w)
Exemple #3
0
decode_para = [para1, para2]
N = 2**n
rate = K / N
SNR = snr_generate.SNR_array(SNR_para)
len_snr = SNR.size
SNR_list = list(SNR)
BER_list = []
BLER_list = []
time_start = time.time()

for i in range(len_snr):
    SNRi = SNR[i]
    run = 1
    error = np.array([0, 0])
    information_pos = construction.construction(N, SNRi, channel_con,
                                                construction_method, K + crc_n,
                                                rate)

    while run <= run_num:
        #print('The run_num is : ' + str(run), end='\r')
        value = polarcodes.polarcodes(n, rate, SNRi, channel_con,
                                      decode_method, decode_para,
                                      information_pos, frozen_bit, crc_n)
        error += value
        run += 1

    ber_bler = np.array([error[0] / (N * rate * run_num), error[1] / run_num])
    print('When SNR= ', SNRi, 'dB, ')
    print('the BER is : ', ber_bler[0], ', and the BLER is : ', ber_bler[1])
    BER_list.append(ber_bler[0])
    BLER_list.append(ber_bler[1])
Exemple #4
0
from solution_class import Solution
from reading import reading
from construction import construction
from lns import lns

for ins in range(1, 21):

    workbook = xlsxwriter.Workbook('JKRlns' + str(ins) + '.xlsx')

    N, M, P, c, a, b = reading(ins)

    cputime = time.time()

    # Initial solution
    F, ns, UB, LB = construction(N, M, P, c, a, b)

    # Improvement
    F, ns = lns(N, M, P, c, a, b, UB, LB, F, ns, cputime)

    name = 'I' + str(ins)
    print(name)
    worksheet = workbook.add_worksheet(name)
    worksheet.write(0, 0, ns)
    print(ns)
    for i in range(ns):
        for j in range(int(F[i].Xs[0]) + 1):
            if j > 0:
                worksheet.write(i + 1, j, F[i].Xs[j] + 1)
            else:
                worksheet.write(i + 1, j, F[i].Xs[j])