A Route Assignment Program Algorithm

前端 未结 2 2034
梦如初夏
梦如初夏 2021-01-07 04:01

What im trying to do, is create a program that will assign a route for a driving test. there will be three diffrent routes, linked together at certain points. Never should t

2条回答
  •  终归单人心
    2021-01-07 04:41

    You should be able to calculate collision times from start.

    Route 1 has 6 points. {A,B,C,D,E,F}

    Route 2 has 5 points. {A,F,G,H,I}

    Route 3 has 6 points. {A,H,K,L,M,N}

    Possible Collisions at: {A,F,H}

    So you need to calculate the following times:

    Route 1: A->F, A->A

    Route 2: A->F, A->H, A->A

    Route 3: A->H, A->A

    From here you can calculate time differences that create a collision.

    If it takes you 20 minutes to go from route 1A to Route 1F and 5 minutes to get from Route 2A to Route 2F, then you know a collision will occur if start an appointment on Route 2 exactly 15 minutes after you began an appointment at Route 1.

    Then you would have a set of non-working collisions:

    Route 1 & 2 collide at: 15, 25, 40

    Route 1 & 3 collide at: 25, 30

    Route 2 & 3 collide at: 30, 40, 45

    From here you should pretty easily be able to create your schedule without collisions.

提交回复
热议问题