{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# SM Interface Sample" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We start by importing the corresponding module :" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pyscheduling.SMSP.interface as sm " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We create an instance of Problem class :" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "\n", "problem = sm.Problem()\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We add constraints :" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "problem.add_constraints([sm.Constraints.W,sm.Constraints.D])\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We select an objective :" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "problem.set_objective(sm.Objective.wiTi)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We either create an instance of the corresponding problem or randomly generate it :" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "problem.generate_random(jobs_number=20,Wmax=10)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, we use one of the implemented methods which are found in either **Heuristics** or **Metaheuristics** classes as following :" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Search stopped with status : FEASIBLE\n", " Solution is : \n", " Objective : 4361\n", "Job_schedule (job_id , start_time , completion_time) | objective\n", "(8, 0, 9) : (16, 9, 18) : (1, 18, 25) : (5, 25, 34) : (11, 34, 63) : (12, 63, 75) : (6, 75, 98) : (14, 98, 110) : (17, 110, 152) : (13, 152, 160) : (18, 160, 177) : (10, 177, 230) : (7, 230, 272) : (3, 272, 294) : (0, 294, 318) : (2, 318, 331) : (19, 331, 380) : (4, 380, 403) : (15, 403, 438) : (9, 438, 482) | 4361 \n", "Runtime is : 0.00017630000002100132s \n", "time to best is : -1s \n", "\n" ] } ], "source": [ "solution = problem.solve(problem.heuristics[\"ACT\"])\n", "print(solution)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.9.12 ('pyscheduling')", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.12" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "fa7cdbb78ab82d427a6b02c171e3c48e0658c2b720f18feff16576a8f3200f32" } } }, "nbformat": 4, "nbformat_minor": 2 }