How to run problem structure form with a ga algorithm=

조회 수: 12 (최근 30일)
Tiago Abreu
Tiago Abreu 2020년 5월 21일
편집: Tiago Abreu 2020년 5월 21일
Hi,
I'm trying to use ga to solve two problems: Mixed integer linear problem and a Mixed integer non linear problem.
I have the problem formulated in the problem strucure. Below are the main parts:
%Parametros
% ------- Decision Variables ------------------------------
Y = optimvar('Y',I,J,'Type','integer','LowerBound',0,'UpperBound',1);% Se o cliente i vai no carro j
V = optimvar('V',J,'Type','integer','LowerBound',0,'UpperBound',1); % Se o carro j esta a ser usado
P = optimvar('P',I,'Type','integer','LowerBound',0,'UpperBound',1); % Se o cliente i vai em partilhado
%Objective function
objfun = sum(V,'all')*preco_dedicado + sum(P,'all')*preco_partilhado ;
temp_prob.Objective = objfun;
%Restrictions
%temp_prob.Constraints.aloc_obrigatoria = aloc_obrigatoria;
temp_prob.Constraints.aloc_obrigatoria_sup = aloc_obrigatoria_sup;
temp_prob.Constraints.aloc_obrigatoria_inf = aloc_obrigatoria_inf;
temp_prob.Constraints.const_X_1 = const_X_1;
temp_prob.Constraints.const_X_2 = const_X_2; temp_prob.Constraints.const_X_3 = const_X_3;
temp_prob.Constraints.veiculo_usado = veiculo_usado;
temp_prob.Constraints.combinacao_possivel = combinacao_possivel;
temp_prob.Constraints.condicao_tempo = condicao_tempo;
%Call Solver
problem = prob2struct(temp_prob);
[x,fval] = ga(problem);
It gives me the following error:
Error using separateOptimStruct (line 25)
Use INTLINPROG function for this problem
structure.
Error in ga (line 263)
[fun,nvars,Aineq,bineq,Aeq,beq,lb,ub,nonlcon,intcon,rngstate,options]
= separateOptimStruct(fun);
Error in modelo_nors_revisto_ga_linear (line 121)
[x,fval] = ga(problem);
Can anyone help?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Perform Sensitivity Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by