コード例 #1
0
def make_data(n, UAV):
    """make_data: compute matrix distance based on euclidean distance"""
    S = Class.Sequence(n, None, None)
    V = []
    for i in range(0, n + 2):  # インスタンス化
        V.append(Class.Node(i))
    for i in range(0, n + 1):  # 0~n n+1はデポ(0)
        V[i].coordinate = [30 * random.random() + 1, 30 * random.random() + 1]
        if i == 0:
            V[i].next = V[i + 1]
        else:
            V[i].prev = V[i - 1]
            V[i].next = V[i + 1]
        S.nodes.append(V[i])
    V[n + 1].coordinate = V[0].coordinate
    V[n + 1].prev = V[n]
    S.first = V[0]
    S.last = V[n + 1]
    global dD, dT, tD, tT
    for i in V:
        for j in V:
            for uav in UAV:
                dD[uav, i.num, j.num] = distance(i.coordinate, j.coordinate)
                tD[uav, i.num, j.num] = dD[uav, i.num, j.num] / _dSpeed
            dT[i.num, j.num] = dD[UAV[0], i.num, j.num] * _biasForDist
            tT[i.num, j.num] = dT[i.num, j.num] / _tSpeed
    return S, V
コード例 #2
0
from datetime import datetime, timedelta
import Class

source = "TestSave1.p"
# source = "TestSave2.p"

epoch = Class.datetime(2019, 3, 13)

A = Class.Node()  # event
A.name = "A"  # name
A.label = "Test_A"
A.dur = 10  # duration
A.dep = []  # dependencies on other events
A.start = datetime(
    2019, 3, 13)  # start time, can be pushed back if dependencies incomplete
A.end = A.start + timedelta(
    days=A.dur)  # end time, can be later than earliest completion time