Add powershell5 profile

This commit is contained in:
Shockwave 2023-11-25 11:17:12 +08:00
parent 6c0cf4d248
commit 0275d21f46
3 changed files with 82 additions and 0 deletions

View File

@ -0,0 +1,20 @@
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
$msg = @"
_____ ______ ________ _____ _____ _ _ ______ _ _ _____
| __ \ / __ \ \ / / ____| __ \ / ____| | | | ____| | | | | ____|
| |__) | | | \ \ /\ / /| |__ | |__) | (___ | |__| | |__ | | | | | |__
| ___/| | | |\ \/ \/ / | __| | _ / \___ \| __ | __| | | | | |___ \
| | | |__| | \ /\ / | |____| | \ \ ____) | | | | |____| |____| |____ ___) |
|_| \____/ \/ \/ |______|_| \_\_____/|_| |_|______|______|______|____/
"@
function Hello {
param (
[string] $Msg
)
Write-Host $Msg -ForegroundColor DarkBlue
}
$(Hello $msg)
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding =
New-Object System.Text.UTF8Encoding

View File

@ -0,0 +1,33 @@
# coding=utf-8
from rsome import dro
# from rsome import grb_solver as grb
from rsome import eco_solver as eco
import rsome as rso
import numpy as np
def simple_linear():
model = dro.Model('LP model') # create a Model object
x = model.dvar() # define a decision variable x
y = model.dvar() # define a decision variable y
model.max(3*x + 4*y) # maximize the objective function
model.st(2.5*x + y <= 20) # specify the 1st constraints
model.st(5*x + 3*y <= 30) # specify the 2nd constraints
model.st(x + 2*y <= 16) # specify the 3rd constraints
model.st(abs(y) <= 2) # specify the 4th constraints
model.solve() # solve the model by the default solver
def main():
model = dro.Model("electricSystem")
# w = model.dvar(w)
model.solve(eco)
if __name__ == "__main__":
# simple_linear()
main()

View File

@ -0,0 +1,29 @@
# coding=utf-8
from rsome import ro
from rsome import eco_solver as grb
import rsome as rso
import numpy as np
def main():
n = 150 # number of stocks
i = np.arange(1, n+1) # indices of stocks
p = 1.15 + i*0.05/150 # mean returns
delta = 0.05/450 * (2*i*n*(n+1))**0.5 # deviations of returns
Gamma = 5 # budget of uncertainty
model = ro.Model()
x = model.dvar(n) # fractions of investment
z = model.rvar(n) # random variables
model.maxmin((p + delta*z) @ x, # the max-min objective
rso.norm(z, np.infty) <= 1, # uncertainty set constraints
rso.norm(z, 1) <= Gamma) # uncertainty set constraints
model.st(sum(x) == 1) # summation of x is one
model.st(x >= 0) # x is non-negative
model.solve(grb) # solve the model by Gurobi
if __name__ == "__main__":
main()