function [c,ceq] = constraint(x)
c = x(1)^2 - x(2)^2 - 1;
% LHS of the inequality nonlinear constraint (RHS left with 0).
% If there is no nonlinear inequality, then c=[];
ceq = x(1)^2 + x(2)^2 - 1;
% LHS of the equality nonlinear constraint (RHS left wit
f=zeros(7,2);
%1=working
%2=broken
p=zeros(6,2);
%in case of working
%1 for do nothing
%2 for maintenence
%in case of broken
%1 for repairing
%2 for replacement
for i=6:-1:1
[f(i,1) p(i,1)] = max([0.3*(100+f(i+1,1)+0.7*f(i+1,2) 0.6*(100+f(i+1,1)+0.4*f(i+
0ata
weights = [4 5 6 7 8 9];
rewards = [9.2 11.9 13.2 15.5 19.9 22.3];
0efine the stages n=1,2,.6 items
N = 6;
0efine number of states 0, 1, .20
S = 20+1;
f = zeros(N,S);
x = zeros(N,S);
for i=N:-1:1
for j = 1:1:S
if (j-1 >= weights(i)
%if current st