{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# A two stage stochastic program\n", "\n", "Assume that you are warming your house with fuel. Currently fuel is at 750€/1000 liters. \n", "You can store up to 1000l for the winter, but you don't know yet how much you will use, and how much it will cost to buy fuel during winter.\n", "\n", "We assume that there are $4$ scenarios, with probabilities $p$, futur fuel cost $c$ and demand $d$ given afterwards.\n", "We want to minimize the expected costs of warming yourself during winter." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "using JuMP, Clp\n", "\n", "S = 4 \n", "p = [0.1 0.4 0.4 0.1]\n", "c0 = 750\n", "c1 = [700 770 900 900]\n", "d = [500 700 800 1000]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 1\n", "\n", "Solve the corresponding 2 stage program. Give the optimal value, and optimal controls." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "m_2S = Model(solver = ClpSolver())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 2\n", "\n", "Solve the open-loop version of this problem. Give the optimal value, and optimal controls.\n", "Check the inequality between the value of the open-loop problem and 2-stage problem." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "m_OL = Model(solver = ClpSolver())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 3\n", "\n", "Solve the anticipative version of this problem. Give the optimal value, and optimal controls. Check the inequality between the value of the anticipative problem and 2-stage problem." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "m_a = Model(solver = ClpSolver())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 4\n", "\n", "We call (P_mean) the problem where cost and demand are replaced by their expectation. Solve this problem, giving value and first and second stage optimal control.\n", "\n", "Evaluate the value of this first stage control, that is the expected cost of using this first stage control with adapted recourse.\n", "\n", "Compare both values to the precedents problems." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "m_mean = Model(solver = ClpSolver())" ] } ], "metadata": { "kernelspec": { "display_name": "Julia 0.6.0", "language": "julia", "name": "julia-0.6" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "0.6.0" } }, "nbformat": 4, "nbformat_minor": 0 }