MILP to select representative points in a set

2 views (last 30 days)
Hello guyz, I'm trying to run this code using the intlinprog to select N rows of data from a matrix with 235 rows and 10 columns with the smaller difference between they boxplots measured by rsme. But I did a code to run one time each from 2 to 235 selected rowns. Someone could help me with the selecting part to calculate the boxplots measurements? Here is the code:
clear all
close all
clc
set(0,'DefaultAxesFontName', 'Times New Roman')
set(0,'DefaultAxesFontSize', 12)
set(0,'DefaultTextFontname', 'Times New Roman')
set(0,'DefaultTextFontSize', 12)
A = MTD.data(:,11:20); % A matriz with 235 rowns and 10 columns
AI = length(A); % All instances
Ipos = (1:1:AI)'; % Datasets positions
ALL = [quantile(A,[0.75 0.5 0.25]);max(A);min(A)]; %boxplot do todo
x_i = optimvar('x_i', AI, 'Type', 'integer', 'LowerBound', 0,'UpperBound',1); % Variables
Sim = 1;
for i = 2 : AI
Sim = Sim + 1
for j=1:AI
TS(j) = Ipos(j)*x_i(j);
end
TS(find(TS==0))=[];
AS = A(TS,:);
NS = length(SLCT);
f = sum(rmse(ALL,AS));
constraint = sum(x_i) == Ipos(i); % One constraint
problem = optimproblem('Objective', f, 'Constraints', constraint); % Problem definition
options = optimoptions('intlinprog', 'Display', 'off'); % solving
[solution,fvalM] = solve(problem, 'Options', options);
x(i-1,:) = solution.x_i;
fval(i-1,1:2) = [fvalM sum(solution.x_i)];
end

Answers (0)

Categories

Find more on Get Started with Optimization Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!