Constraint Formulation doesnt work / is not applied to solution
이전 댓글 표시
Hi everybody,
I have a problem with a specific constraint formulation. the problem requires to choose 4 players from a player pool (its a soccer problem) and maximizes expected points.
I want the optimizer to only pick players from a certain number of teams. For this I tried to use this:
% defining a new optimization variable
used_teams = optimvar('used_teams',length(teams),1,'Type','integer','LowerBound',0,'UpperBound',1);
% run variables
i = 1:length(teams);
t = 1:length(player_def);
%apply team info to optimization variable
soccer_lineup.Constraints.stack1 = used_teams(i) <= sum(def_team_info(i,t)*defense_lineup(t));
%set the maximum numbers of teams
def_teams = sum(used_teams);
soccer_lineup.Constraints.stack2 = def_teams <= 2;
My inspiration to code it like this came from a Github code in another language looking very similar:

The problem is, that it isnt applied to the problem. I can set the number of used teams to 0 and I still get a feasible solution (which should be impossible).(Yes the example from the other code is for more than 3 teams, but i want the optimizer to stack players from 2 teams. )
Does anyone see the mistake?
I would appreciate your help.
Kind regards,
Christian
댓글 수: 8
Walter Roberson
2019년 12월 13일
When you say that you set the number of used teams to 0 do you mean that you change the upper bound in the optimization to 0 thereby forcing the vector to be all 0?
Christian Schumacher
2019년 12월 13일
Walter Roberson
2019년 12월 13일
It would help to have all your code.
Christian Schumacher
2019년 12월 14일
Christian Schumacher
2019년 12월 14일
Christian Schumacher
2019년 12월 17일
Walter Roberson
2019년 12월 18일
The input file would help. There is too much code for me to read it and mentally model it all and figure out all the combinations of circumstances in an input file that could potentially lead to problems.
Christian Schumacher
2019년 12월 19일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!