Networks and project planning
net shortest_pathnet shortest_pathnet max_flownet max_flownet min_cost_flownet mstnet mstnet cpmnet cpm

net shortest_path <json_edges> <source>


Description

    Shortest paths from a source (Dijkstra, or Bellman-Ford when a weight is negative): distance to every node

Parameters

    json_edges:   The edges [from, to, weight] - String - required
    source:   The source node - String - required
admin
net shortest_path "[[\"A\", \"B\", 4], [\"A\", \"C\", 2], [\"C\", \"B\", 1], [\"B\", \"D\", 5], [\"C\", \"D\", 8], [\"D\", \"E\", 3]]" "A"
mentdb
{"source": "A", "algorithm": "Dijkstra", "distances": {"A": 0, "B": 3, "C": 2, "D": 8, "E": 11}}

net shortest_path <json_edges> <source> <json_params>


Description

    Shortest path with parameters: target (gives the path), directed (true)

Parameters

    json_edges:   The edges - String - required
    source:   The source - String - required
    json_params:   The parameters - String - required
admin
net shortest_path "[[\"A\", \"B\", 4], [\"A\", \"C\", 2], [\"C\", \"B\", 1], [\"B\", \"D\", 5], [\"C\", \"D\", 8], [\"D\", \"E\", 3]]" "A" "{\"target\": \"E\", \"directed\": false}"
mentdb
{"source": "A", "algorithm": "Dijkstra", "distances": {"A": 0, "B": 3, "C": 2, "D": 8, "E": 11}, "path": ["A", "C", "B", "D", "E"], "length": 11}

net max_flow <json_edges> <source> <sink>


Description

    Maximum flow from a source to a sink (Edmonds-Karp), the flow on each edge and the minimum cut (the bottleneck edges)

Parameters

    json_edges:   The edges [from, to, capacity] - String - required
    source:   The source - String - required
    sink:   The sink - String - required
admin
net max_flow "[[\"s\", \"v1\", 16], [\"s\", \"v2\", 13], [\"v2\", \"v1\", 4], [\"v1\", \"v3\", 12], [\"v3\", \"v2\", 9], [\"v2\", \"v4\", 14], [\"v4\", \"v3\", 7], [\"v3\", \"t\", 20], [\"v4\", \"t\", 4]]" "s" "t"
mentdb
{"max_flow": 23, "flows": [{"from": "s", "to": "v1", "capacity": 16, "flow": 12}, {"from": "s", "to": "v2", "capacity": 13, "flow": 11}, {"from": "v2", "to": "v1", "capacity": 4, "flow": 0}, {"from": "v1", "to": "v3", "capacity": 12, "flow": 12}, {"from": "v3", "to": "v2", "capacity": 9, "flow": 0}, {"from": "v2", "to": "v4", "capacity": 14, "flow": 11}, {"from": "v4", "to": "v3", "capacity": 7, "flow": 7}, {"from": "v3", "to": "t", "capacity": 20, "flow": 19}, {"from": "v4", "to": "t", "capacity": 4, "flow": 4}], "min_cut": [{"from": "v1", "to": "v3", "capacity": 12}, {"from": "v4", "to": "v3", "capacity": 7}, {"from": "v4", "to": "t", "capacity": 4}], "source_side": ["s", "v1", "v2", "v4"]}

net max_flow <json_edges> <source> <sink> <json_params>


Description

    Maximum flow with parameters: directed

Parameters

    json_edges:   The edges - String - required
    source:   The source - String - required
    sink:   The sink - String - required
    json_params:   The parameters - String - required
admin
net max_flow "[[\"a\", \"b\", 5], [\"b\", \"c\", 3], [\"a\", \"c\", 2]]" "a" "c" "{\"directed\": false}"
mentdb
{"max_flow": 5, "flows": [{"from": "a", "to": "b", "capacity": 5, "flow": 3}, {"from": "b", "to": "c", "capacity": 3, "flow": 3}, {"from": "a", "to": "c", "capacity": 2, "flow": 2}], "min_cut": [{"from": "b", "to": "c", "capacity": 3}, {"from": "a", "to": "c", "capacity": 2}], "source_side": ["a", "b"]}

net min_cost_flow <json_edges> <json_supplies>


Description

    Minimum cost flow (transshipment): edges [from, to, capacity, unit cost], supplies {node: supply > 0 or demand < 0}; flows and total cost

Parameters

    json_edges:   The edges - String - required
    json_supplies:   The supplies and demands - String - required
admin
net min_cost_flow "[[\"plant\", \"w1\", 60, 2], [\"plant\", \"w2\", 60, 3], [\"w1\", \"s1\", 40, 4], [\"w1\", \"s2\", 40, 6], [\"w2\", \"s2\", 40, 3], [\"w2\", \"s3\", 40, 5], [\"w1\", \"w2\", 20, 1]]" "{\"plant\": 90, \"s1\": -30, \"s2\": -35, \"s3\": -25}"
mentdb
{"total_cost": 590, "total_flow": 90, "flows": [{"from": "plant", "to": "w1", "flow": 30, "cost": 60}, {"from": "plant", "to": "w2", "flow": 60, "cost": 180}, {"from": "w1", "to": "s1", "flow": 30, "cost": 120}, {"from": "w2", "to": "s2", "flow": 35, "cost": 105}, {"from": "w2", "to": "s3", "flow": 25, "cost": 125}]}

net mst <json_edges>


Description

    Minimum spanning tree (Kruskal): the cheapest set of edges connecting all the nodes (cables, pipes, roads)

Parameters

    json_edges:   The edges [from, to, weight] - String - required
admin
net mst "[[\"A\", \"B\", 4], [\"A\", \"H\", 8], [\"B\", \"H\", 11], [\"B\", \"C\", 8], [\"H\", \"I\", 7], [\"H\", \"G\", 1], [\"I\", \"G\", 6], [\"C\", \"I\", 2], [\"C\", \"F\", 4], [\"G\", \"F\", 2], [\"C\", \"D\", 7], [\"D\", \"F\", 14], [\"D\", \"E\", 9], [\"E\", \"F\", 10]]"
mentdb
{"total_weight": 37, "edges": [{"from": "H", "to": "G", "weight": 1}, {"from": "C", "to": "I", "weight": 2}, {"from": "G", "to": "F", "weight": 2}, {"from": "A", "to": "B", "weight": 4}, {"from": "C", "to": "F", "weight": 4}, {"from": "C", "to": "D", "weight": 7}, {"from": "A", "to": "H", "weight": 8}, {"from": "D", "to": "E", "weight": 9}], "nodes": 9, "components": 1}

net mst <json_edges> <json_params>


Description

    Spanning tree with parameters: maximize (maximum spanning tree)

Parameters

    json_edges:   The edges - String - required
    json_params:   The parameters - String - required
admin
net mst "[[\"A\", \"B\", 4], [\"B\", \"C\", 2], [\"A\", \"C\", 5]]" "{\"maximize\": true}"
mentdb
{"total_weight": 9, "edges": [{"from": "A", "to": "C", "weight": 5}, {"from": "A", "to": "B", "weight": 4}], "nodes": 3, "components": 1}

net cpm <json_activities>


Description

    Critical path of a project (CPM): early and late starts and finishes, slack of each activity, critical activities and project duration

Parameters

    json_activities:   The activities {name, duration, predecessors} - String - required
admin
net cpm "[{\"name\": \"specs\", \"duration\": 3}, {\"name\": \"design\", \"duration\": 4, \"predecessors\": [\"specs\"]}, {\"name\": \"purchase\", \"duration\": 2, \"predecessors\": [\"specs\"]}, {\"name\": \"build\", \"duration\": 5, \"predecessors\": [\"design\", \"purchase\"]}, {\"name\": \"training\", \"duration\": 1, \"predecessors\": [\"purchase\"]}, {\"name\": \"go-live\", \"duration\": 2, \"predecessors\": [\"build\", \"training\"]}]"
mentdb
{"project_duration": 14, "critical_path": ["specs", "design", "build", "go-live"], "activities": [{"activity": "specs", "duration": 3, "early_start": 0, "early_finish": 3, "late_start": 0, "late_finish": 3, "slack": 0, "critical": true}, {"activity": "design", "duration": 4, "early_start": 3, "early_finish": 7, "late_start": 3, "late_finish": 7, "slack": 0, "critical": true}, {"activity": "purchase", "duration": 2, "early_start": 3, "early_finish": 5, "late_start": 5, "late_finish": 7, "slack": 2, "critical": false}, {"activity": "build", "duration": 5, "early_start": 7, "early_finish": 12, "late_start": 7, "late_finish": 12, "slack": 0, "critical": true}, {"activity": "training", "duration": 1, "early_start": 5, "early_finish": 6, "late_start": 11, "late_finish": 12, "slack": 6, "critical": false}, {"activity": "go-live", "duration": 2, "early_start": 12, "early_finish": 14, "late_start": 12, "late_finish": 14, "slack": 0, "critical": true}]}
Complete: a planning table -> critical path -> the activities with a slack
admin
json load "tuto_p" (net cpm "[{\"name\": \"specs\", \"duration\": 3}, {\"name\": \"design\", \"duration\": 4, \"predecessors\": [\"specs\"]}, {\"name\": \"purchase\", \"duration\": 2, \"predecessors\": [\"specs\"]}, {\"name\": \"build\", \"duration\": 5, \"predecessors\": [\"design\", \"purchase\"]}, {\"name\": \"training\", \"duration\": 1, \"predecessors\": [\"purchase\"]}, {\"name\": \"go-live\", \"duration\": 2, \"predecessors\": [\"build\", \"training\"]}]"); -> "[res]" (concat "duration " (json select "tuto_p" "/project_duration") ", slack: "); for (-> "[i]" 0) (< [i] (json count "tuto_p" "/activities")) (++ "[i]") { if (> (json select "tuto_p" (concat "/activities/[" [i] "]/slack")) 0) {-> "[res]" (concat [res] (json select "tuto_p" (concat "/activities/[" [i] "]/activity")) " " (json select "tuto_p" (concat "/activities/[" [i] "]/slack")) " ");}; }; json unload "tuto_p"; [res]
mentdb
duration 14, slack: purchase 2 training 6

net cpm <json_activities> <json_params>


Description

    PERT (three estimates optimistic, likely, pessimistic for each activity): expected durations, sd of the project and probability to finish by a deadline

Parameters

    json_activities:   The activities - String - required
    json_params:   The parameters: deadline - String - required
admin
net cpm "[{\"name\": \"A\", \"optimistic\": 2, \"likely\": 3, \"pessimistic\": 6}, {\"name\": \"B\", \"optimistic\": 3, \"likely\": 4, \"pessimistic\": 8, \"predecessors\": \"A\"}, {\"name\": \"C\", \"optimistic\": 1, \"likely\": 2, \"pessimistic\": 3, \"predecessors\": \"A\"}]" "{\"deadline\": 9}"
mentdb
{"project_duration": 7.833333333333334, "critical_path": ["A", "B"], "project_sd": 1.0671873729054748, "deadline": 9, "probability_on_time": 0.8628505863020619, "activities": [{"activity": "A", "duration": 3.3333333333333335, "early_start": 0, "early_finish": 3.333333333, "late_start": 0, "late_finish": 3.333333333, "slack": 0, "critical": true, "sd": 0.6666666666666666}, {"activity": "B", "duration": 4.5, "early_start": 3.333333333, "early_finish": 7.833333333, "late_start": 3.333333333, "late_finish": 7.833333333, "slack": 0, "critical": true, "sd": 0.8333333333333334}, {"activity": "C", "duration": 2, "early_start": 3.333333333, "early_finish": 5.333333333, "late_start": 5.833333333, "late_finish": 7.833333333, "slack": 2.4999999999999996, "critical": false, "sd": 0.3333333333333333}]}
Used in use cases (1 recipe)

    Mechanical & civil engineer › Building project: critical path and probability to deliver on time (PERT)