File: checkControlMaps.py

package info (click to toggle)
stopt 5.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,772 kB
  • sloc: cpp: 70,373; python: 5,942; makefile: 67; sh: 57
file content (61 lines) | stat: -rw-r--r-- 1,619 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Copyright (C) 2018 The Regents of the University of California
# All Rights Reserved
# This code is published under the GNU Lesser General Public License (GNU LGPL)
# Authors - Aditya Maheshwari and Mike Ludkovski
#           Department of Statistics and Applied Probability,
#           University of California at Santa Barbara

from __future__ import division
import numpy as np
import math
import matplotlib
# matplotlib.use('Agg')
import matplotlib.pyplot as plt
import time

import parameters as bv
import simulateState_new as simX
import valueNext_new as fv


import StOptGrids
import StOptReg
import StOptGeners



if __name__ == "__main__":

    outSampleSimul = 10000

    param = bv.basicVariables()

    condExpFilePath = 'condExp_rmcType_gd_regType_piecewiseLinear'
    
    I0 = np.random.uniform(param.I_minMax[0],param.I_minMax[1],(outSampleSimul,1))
    Xt = np.random.uniform(-8,8,(outSampleSimul,1))
    
    r,c = Xt.shape

    It = np.zeros((r,2)) # inventory evolution
    It[:,0] = I0[:,0]

    Dt = np.zeros((r,2), dtype=np.int) # clock 
    Dt[:,0] = 1  #initial regime

    St = np.zeros((r,c)) # stores Xt - dt - Bt
    Bt = np.zeros((r,c)) # battery output
    dt = np.zeros((r,c)) # diesel output

    archiveToRead =  StOptGeners.BinaryFileArchive(condExpFilePath,"r")


    contValues = archiveToRead.readGridAndRegressedValue(20,"toStore")

    for sim in range(outSampleSimul):
        _, dt[sim, 0], St[sim, 0], It[sim, 1] ,Bt[sim, 0] = fv.findOptimalControl(Xt[sim,0], It[sim,0], Dt[sim,0], contValues[0], param)


    plt.scatter(Xt[:,0],It[:,0],c=dt[:,0])
    plt.show()