{ "cells": [ { "cell_type": "code", "execution_count": 7, "outputs": [ { "data": { "text/plain": "Cotta" }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "examples.Quarter.Cotta" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 9, "outputs": [ { "data": { "text/html": "
\n " }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": " " }, "metadata": {}, "output_type": "display_data" } ], "source": [ "@file:DependsOn(\"com.github.holgerbrandl:kalasim:0.9-SNAPSHOT\")" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": true }, "outputs": [], "source": [ "\n", "import org.kalasim.*\n", "import examples.*\n", "import examples.TaxiStatus.*\n", "import org.kalasim.*\n", "import java.awt.Point\n", "import kotlin.math.absoluteValue\n", "import kotlin.time.Duration.Companion.days\n", "import kotlin.time.Duration.Companion.hours\n", "import kotlin.time.Duration.Companion.minutes" ] }, { "cell_type": "code", "execution_count": 11, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Line_14.jupyter-kts (4:1 - 17) Cannot access class 'org.kalasim.Environment'. Check your module classpath for missing or conflicting dependencies\n", "Line_14.jupyter-kts (7:13 - 23) Variable 'dispatcher' is never used\n", "Line_14.jupyter-kts (7:26 - 36) Cannot access class 'org.kalasim.Environment'. Check your module classpath for missing or conflicting dependencies\n", "Line_14.jupyter-kts (9:13 - 18) Variable 'delay' is never used\n", "Line_14.jupyter-kts (9:21 - 28) Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: \n", "public fun SimContext.uniform(lower: Number = ..., upper: Number = ...): UniformRealDistribution defined in org.kalasim\n", "Line_14.jupyter-kts (11:9 - 27) Cannot access class 'org.kalasim.TickTime'. Check your module classpath for missing or conflicting dependencies\n", "Line_14.jupyter-kts (11:9 - 27) Cannot access class 'org.kalasim.Priority'. Check your module classpath for missing or conflicting dependencies\n", "Line_14.jupyter-kts (11:28 - 35) Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: \n", "public fun SimContext.uniform(lower: Number = ..., upper: Number = ...): UniformRealDistribution defined in org.kalasim\n", "Line_14.jupyter-kts (15:13 - 18) Cannot access class 'org.kalasim.TickTime'. Check your module classpath for missing or conflicting dependencies\n", "Line_14.jupyter-kts (15:43 - 46) Unresolved reference: env\n", "Line_14.jupyter-kts (18:9 - 12) Cannot access class 'org.kalasim.Environment'. Check your module classpath for missing or conflicting dependencies\n", "Line_14.jupyter-kts (18:13 - 19) Type mismatch: inferred type is Duration but TypeVariable(T).() -> TypeVariable(R) was expected" ] } ], "source": [ "\n", "createSimulation(enableComponentLogger = true) {\n", " val taxis = List(10) { Taxi() }\n", "\n", " val dispatcher = dependency { FifoDispatcher(taxis) }\n", "\n", " val delay = uniform(0, 60).minutes\n", "\n", " ComponentGenerator(uniform(0, 3)) {\n", " val departure = Quarter.values().random()\n", " val destination = Quarter.values().asList().minusElement(departure).random()\n", "\n", " Order(departure, destination, env.now + delay())\n", " }\n", "\n", " run(2.days)\n", " println(\"sim completed\")\n", " }" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [], "metadata": { "collapsed": false } } ], "metadata": { "kernelspec": { "display_name": "Kotlin", "language": "kotlin", "name": "kotlin" }, "language_info": { "name": "kotlin", "version": "1.8.0-dev-3517", "mimetype": "text/x-kotlin", "file_extension": ".kt", "pygments_lexer": "kotlin", "codemirror_mode": "text/x-kotlin", "nbconvert_exporter": "" } }, "nbformat": 4, "nbformat_minor": 0 }