{ "cells": [ { "cell_type": "markdown", "id": "74b633f7", "metadata": {}, "source": [ "# Random Actions" ] }, { "cell_type": "code", "execution_count": null, "id": "281b5644", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from graph_jsp_env.disjunctive_graph_jsp_env import DisjunctiveGraphJspEnv" ] }, { "cell_type": "code", "execution_count": null, "id": "100c9a2c", "metadata": {}, "outputs": [], "source": [ "jsp = np.array([\n", " [[1, 2, 0], # job 0\n", " [0, 2, 1]], # job 1\n", " [[17, 12, 19], # task durations of job 0\n", " [8, 6, 2]] # task durations of job 1\n", "])" ] }, { "cell_type": "code", "execution_count": null, "id": "5e41b913", "metadata": {}, "outputs": [], "source": [ "env = DisjunctiveGraphJspEnv(\n", " jps_instance=jsp,\n", " perform_left_shift_if_possible=True,\n", " normalize_observation_space=True, # see documentation of DisjunctiveGraphJspEnv::get_state for more information\n", " flat_observation_space=True, # see documentation of DisjunctiveGraphJspEnv::get_state for more information\n", " action_mode='task', # alternative 'job'\n", " dtype='float32' # dtype of the observation space\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "5cf9d54e", "metadata": {}, "outputs": [], "source": [ "terminated = False\n", "info = {}\n", "for i in range(6):\n", " # get valid action mask. sample expects it to be a numpy array of type int8\n", " mask = np.array(env.valid_action_mask()).astype(np.int8)\n", " action = env.action_space.sample(mask=mask)\n", " state, reward, terminated, truncated, info = env.step(action)\n", " # chose the visualisation you want to see using the show parameter\n", " # console rendering\n", " env.render(show=[\"gantt_console\", \"graph_console\"])" ] }, { "cell_type": "code", "execution_count": null, "id": "9f499f2c", "metadata": {}, "outputs": [], "source": [ "print(f\"makespan: {info['makespan']}\")" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }