Syntax for optimization with integer and continuous variables, nonlinear equalities and inequalities?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Happy holidays!
I am trying to write an optimization problem that has (i) integer and continuous variables and (ii) nonlinear equalities and inequalities. Without going into details, the problem is something along the lines of:
x = optimvar('x', 5, 'Type', 'integer', 'LowerBound', 0, 'UpperBound', 1);
y = optimvar('u', 5, 'LowerBound',[-Inf(4,1); 1], ...
'UpperBound', [Inf(4,1); 1]);
A = optimconstr(10);
B = optimconstr(10);
for i=1:10
A(i) = f(x, y) == 0;
B(i) = g(x, y) >= 0;
end
obj = h(x, y);
prob.Objective = obj;
prob.Constraints.A = A;
prob.Constraints.B = B;
[sol, val] = solve(prob)
When I run this on its own, I receive the error:
Error using optim.problemdef.OptimizationProblem/solve
GA does not solve problems with integer and equality
constraints.
For more help see No Equality Constraints in the
documentation.
As an aside, when I try to click on No Equality Constraints, I also get an error:
Error using helpview
Topic ID (no_eqcon_intga) not found in gads.
When I try to switch to use fmincon by adding:
options = optimoptions('fmincon', 'Algorithm', 'interior-point', 'Display', 'iter');
x0 = repelem([1], 5);
u0 = repelem([1], 5);
xu0.x = x0;
xu0.u = u0;
[sol, val] = solve(prob, xu0, options);
I receive the error:
Error using optim.internal.problemdef.ProblemImpl/solveImpl
The value of 'GlobalSolver' is invalid. GlobalSolver
must be a MultiStart or GlobalSearch object.
Error in optim.problemdef.OptimizationProblem/solve
Some guidance on the proper syntax, or at least a reference I can look at, would be greatly appreciated!
0 Kommentare
Antworten (3)
Torsten
am 22 Dez. 2023
Concerning your attempt with "ga":
See the Note below from the documentation of "ga":
x = ga(fun,nvars,A,b,Aeq,beq,lb,ub,nonlcon,intcon,options) requires that the variables listed in intcon take integer values.
Note
When there are integer constraints, ga does not accept nonlinear equality constraints, only nonlinear inequality constraints.
Concerning your attempt with "fmincon":
fmincon only accepts continuous solution variables, no binaries as you define for x.
Thus summarizing:
Your problem as stated is not solvable within the MATLAB optimization environment.
0 Kommentare
Walter Roberson
am 22 Dez. 2023
Bearbeitet: Walter Roberson
am 22 Dez. 2023
You just cannot do that using ga().
You can potentially do that using surrogateopt()
... But there is a lot to be said for @Matt J's suggestion of running once for each of the possible x values and find the best overall soltuion.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Surrogate Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!