Solving simple stochastic optimization problems with AMPL

For different risk measures as min of CVaR,you wrote below AMPL,I want to do for portfolio like min variance ,how can I do?

%%writefile model4.mod

param samples > 0;             # number of samples
param demand{1..samples} >= 0; # demand for each sample
param cost > 0;                # procurement cost of each unit
param retail >= 0;             # selling price of each unit
param recover < cost;          # liquidation price of each unit
param minrev;                  # bound on minimum revenue
param maxrev;                  # bound on maximum revenue
param alpha >= 0, <= 1;        # value at risk

var order >= 0;                                # number of units to order
var sales{i in 1..samples} >= 0, <= demand[i]; # sales of each sample
var discount{1..samples} >= 0;                 # scraped units of each sample
var profit{1..samples} >= minrev, <= maxrev;   # profit of each sample
var nu >= minrev, <= maxrev;
var excess{1..samples} >= 0, <= maxrev - minrev;

# minimize CVaR
minimize obj: nu + (1.0 / ((1 - alpha) * samples)) * sum{i in 1..samples} excess[i];

# profit of each sample
s.t. sample_profit {i in 1..samples}: profit[i] == -cost * order + retail * sales[i] + recover * discount[i];
# sales and discount of each sample
s.t. sample_sales {i in 1..samples}: sales[i] + discount[i] == order;
# relation between excess and profit of each sample
s.t. sample_excess {i in 1..samples}: -profit[i] - nu <= excess[i];

I did not understand excess[i],how can I construct for portfolio,I want weights,there is no weights?
I want to solve
image
I wrote for Markowitz minimization variance:
weekly_returns = train_assets.pct_change().fillna(method=‘bfill’)#dropna var normalde ama o 11 den 10 a dusuruyor periyodumuzu ama ben 11 de devam etmek istiyourm
mean_return = weekly_returns.mean()
weekly_returns[“Date”] = weekly_returns.index.format()
weekly_returns.set_index(“Date”, inplace=True)
S= np.cov(train_assets, rowvar=False)
ampl = AMPL()
ampl.eval(
r"“”
set A ordered;
param S{A, A};
param mu{A};
param lb default 0;
param ub default 1;
var w{A} >= lb <= ub;
minimize portfolio_variance:
sum {i in A, j in A} w[i] * S[i, j] * w[j];
s.t. portfolio_weights:
sum {i in A} w[i] = 1;
“”"
)
ampl.set[“A”] = tickers
ampl.param[“S”] = pd.DataFrame(S, index=tickers, columns=tickers)
ampl.param[“mu”] = mean_return
ampl.option[“solver”] = “gurobi”
ampl.solve()
What is the equivalent form for CVaR? @fdabrandao