I am trying to write a linear programming problem problem in JuMP but I am getting error messages. I have given my code below, and I believe the issue is in definition of the constraint. Please can someone help to fix the code?

Apologies the format makes it difficult to read the code, but I cannot see an option to send the code as an attachment.

using JuMP

using Cbc

# Preparing an optimization model

myModel = Model(with_optimizer(Cbc.Optimizer))

prices = [99.74 91.22 98.71 103.75 97.15]

cashFlows = [4 5 2.5 5 4 4 5 2.5 5 4 4 5 2.5 5 4 4 5 2.5 5 4 4 5 102.5 5 4 4 5 0 105 104 4 105 0 0 0 104 0 0 0 0]

Liab_CFs = [5 7 7 6 8 7 20 0]â€™*1000

nt=size(cashFlows,1)

nb=size(cashFlows,2)

Rates = [0.01 0.015 0.017 0.019 0.02 0.025 0.027 0.029]â€™

Disc= [0.99009901 0.970661749 0.950686094 0.927477246 0.90573081 0.862296866 0.829863942 0.795567442]

#Number of bonds available

nBonds = [10 100 20 30 5]â€™

# Declaring variables

@variable(myModel, 0<= x <=nBonds)

# Setting the objective

# The objective is to determine the cheapest set of bonds to cover liability cash flows subject to the constraint below.

@objective(myModel,Min,prices*x)

# Add constraint

# The constraint is determined by cash flows shortfall calculated as net cash flows (bonds cash flows - liability cash flows)

# compounded at forward rate (B), and discounted to time zero. The maximum shortfall should be less than or equal to 0.05*53.844.

# The max is linearized by setting each element in the matrix to be less than or equal to 0.05*53.844

B=[1.01 1.020024752 1.02101183 1.02502363 1.024009823 1.050370059 1.039082218 1.043109481]â€™

A=-(cashFlows*x-Liab_CFs)
d=cumprod(B[1:end-1])
d=[1 d[:]]â€™;
M=tril(d./transpose(d))
@constraint(myModel, constraint1, ((M*A).

*Disc)<=0.05*53.844)

# M*A is doing the following operation

# M*A=[A[1];A[1]*B[1]+A[2];(A[1]*B[1]+A[2])*B[2]+A[3];(A[1]*B[1]+A[2])*B[2]+A[3])*B[3]+A[4];â€¦

# ((A[1]*B[1]+A[2])*B[2]+A[3])*B[3]+A[4])*B[4]+A[5]

# (((A[1]*B[1]+A[2])*B[2]+A[3])*B[3]+A[4])*B[4]+A[5])*B[5]+A[6];â€¦

# ((((A[1]*B[1]+A[2])*B[2]+A[3])*B[3]+A[4])*B[4]+A[5])*B[5]+A[6])*B[6]+A[7];â€¦

# (((((A[1]*B[1]+A[2])*B[2]+A[3])*B[3]+A[4])*B[4]+A[5])*B[5]+A[6])*B[6]+A[7])*B[7]+A[8]]

# Printing the prepared optimization model

print(myModel)

# Solving the optimization problem

optimize!(myModel)

# Printing the optimal solutions obtained

println(â€śOptimal Solutions:â€ť)

println("x = ", JuMP.value(x))