Giter Site home page Giter Site logo

noncomputable / agentmaps Goto Github PK

View Code? Open in Web Editor NEW
906.0 27.0 40.0 7.48 MB

Make social simulations on real maps! Agent-based modeling for the web.

Home Page: https://noncomputable.github.io/AgentMaps/

License: BSD 2-Clause "Simplified" License

JavaScript 100.00%
agent-based-modeling agent-based-simulation gis geographical-information-system geospatial maps leaflet leaflet-plugin javascript

agentmaps's People

Contributors

lpmi-13 avatar noncomputable avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

agentmaps's Issues

agentmaps.js un-minifying

I wanted to see the code of agentmaps.js un-minified to work on path finding algorithms. I am very new to javascript. Please overlook my ignorance. While I was working on unminifying, the beautifiers do not un-minify the strings of eval functions.

The minified file is very hard to read and understand. Can I know what tool did you use to minify the agentmaps.js file. And, is there any way I can unminify the agentmaps.js file?

I tried very hard to unminify it, but I cannot find any tool that properly beautifies the code with proper indentation.

Round trip feature

Did a problem you had inspire this feature request?
I was looking for a way to make the agents take alternate routes to commute between two points, not only the shortest path. I was also looking for a way to make the agent do a round trip. Is there any way I can do that?

Skipping Buildings?

What would be the best approach to skip buildings altogether? I'm only looking to simulate agents on a street network and I want the street network to be considerably bigger than in the demos (whole city if possible). Awesome library btw! Thank you for your work!

Minor fix in documentation

Hi Andrew,

Thank you for the amazing work on building simulation systems on real-world maps.

I would like to report two minor issues regarding the documentation.

Issue 1
In the documentation, under the section Generating buildings (and also the devdocs version), the bounding box is listed as the second argument

agentmap.buildingify(my_data, [[43.3071, -88.0158], [43.2884, -87.9759]]);

but in the implementation, it seems to be the first argument

function buildingify(bounding_box, OSM_data, street_options, unit_options, unit_layers, street_layers) {

The same issue also appears in the quick start guide.

As a result, the console throws an error Uncaught TypeError: OSM_data.features is undefined when the example is ran.

How to reproduce it: Here is the relevant HTML file.

<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
   integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
   crossorigin=""/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
   integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
   crossorigin=""></script>
<script src="https://noncomputable.github.io/AgentMaps/resources/map_data.js"></script>
<script src="https://unpkg.com/agentmaps@2/site/dist/agentmaps.js"></script>
</head>

<body>
<div id="demo_map" style="height:400px"></div>

<script>
    let bounding_points = [[39.9058, -86.0910], [39.8992, -86.1017]]; 
    let leaflet_map = L.map("demo_map").fitBounds(bounding_points);
    L.tileLayer(
        "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", 
        { attribution: "Thanks to <a href=\"http://openstreetmap.org\">OpenStreetMap</a> community" }
    ).addTo(leaflet_map);
    let agentmap = L.A.agentmap(leaflet_map);
    agentmap.buildingify(map_data, bounding_points);
</script>
</body>
</html>

How to see it: Open the html file and check the error in the console.
Expected behavior: Bounding box should come first in the documentation.
More details: N/A

Issue 2
In the quick start guide, near the bottom,

agentmap.controller = function() {
    if (agentmap.state.ticks % 300 === 0) {
        agentmap.agents.eachLayer(function(agent) {
            let random_index = Math.floor(agentmap.units.count() * Math.random()),
            random_unit = agentmap.units.getLayers()[random_index],
            random_unit_id = agentmap.units.getLayerId(random_unit),
            random_unit_center = random_unit.getBounds().getCenter();

            agent.scheduleTrip(random_unit_center, {type: "unit", id: random_unit_id}, 1, false, true);
        }
    }

    agent.moveIt();
}

In the agent.moveIt() line, agent is not bounded. The console throws Uncaught ReferenceError: agent is not defined. Also there is a missing closing round bracket three lines above. Just a typo.

How to reproduce it: Continuing from the last HTML, add to the last script tag

    // continue from the HTML above
    agentmap.buildingify(bounding_points, map_data);   // This line is fixed.
    agentmap.agentify(50, agentmap.seqUnitAgentMaker)
    agentmap.controller = function() {
        if (agentmap.state.ticks % 300 == 0) {
            agentmap.agents.eachLayer(function(agent) {
                let random_index = Math.floor(agentmap.units.count() * Math.random()),
                    random_unit = agentmap.units.getLayers()[random_index],
                    random_unit_id = agentmap.units.getLayerId(random_unit),
                    random_unit_center = random_unit.getBounds().getCenter()
                agent.scheduleTrip(random_unit_center, { type: "unit", id: random_unit_id }, 1, false, true)
            })  // adds a closed round bracket here
        }
    agent.moveIt()
}
agentmap.run()

How to see it: Open the HTML file and check the error in the console.
Expected behavior: agent.moveIt() should be

agentmap.agents.eachLayer(function(agent) { agent.moveIt(); } )

More details: N/A

Thank you again for your work. Your doc explains the library so well. It is among the best I have seen.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.