Minimization with discrete variable
Show older comments
I have some discrete variables of motor torque and speed. Ex: motor 1 has 6 Nm torque and 42 rpm, motor 2 has 9 Nm torque and 62 rpm, etc. I have to find the correct motor specification when applied on some mechanism and load and I already had the linearized function of this mechanism. I have to use optimization tool on Matlab. How can I put the discrete variable into matlab and how can I do the optimization? Really need help.
3 Comments
jgg
on 12 Jan 2016
I'm unclear what you're trying to do here. Describe, if you can, clearly what the outcome variable you're trying to minimize, what the choice variables are, and how they're related.
Rudi Gunawan
on 12 Jan 2016
jgg
on 12 Jan 2016
I assume the secondary issue is that you have a very very large number of these so that enumeration is not feasible?
Accepted Answer
More Answers (2)
Alan Weiss
on 12 Jan 2016
0 votes
If you can specify your problem as a mixed-integer linear programming problem, use the intlinprog function. There are several examples on that page that can help you with problem formulation.
If it is impossible to put into the MILP framework, use the ga solver from Global Optimization Toolbox to solve your mixed integer optimization. You might find some help in this example.
Alan Weiss
MATLAB mathematical toolbox documentation
It's a little bit unclear what your objective function is, but suppose it's something like f(A,B) where A and B are your discrete random variables. Provided that you have only a few levels of the random variables, you could make a nice program like this where:
A = [1,2,3,4]; B = [1,2,3,4];
Then, set something like:
a_val = @(x)(1*x(1)+2*x(2)+3*x(3)+4*x(4));
b_val = @(x)(1*x(1)+2*x(2)+3*x(3)+4*x(4));
Then, your objective function is f(a_val(x),b_val(y)) and you have the restriction your lower bound is zero and upper bound is one, and x and y sum to 1. You could then easily use ga to solve this by following the documentation.
An alternative if you have many levels is to make the variable the level:
f(A(la),B(lb))
where la and lb are the levels, and you restrict them to be between 1 and k where k is the number of levels. I think ga would work well here as well.
It's a little hard to give you more direct advice without more information.
6 Comments
Rudi Gunawan
on 13 Jan 2016
Rudi Gunawan
on 13 Jan 2016
Edited: Rudi Gunawan
on 13 Jan 2016
Rudi Gunawan
on 13 Jan 2016
Torsten
on 13 Jan 2016
This should be done in MATLAB, too.
It avoids that you have to calculate 128 values with a table calculator.
Best wishes
Torsten.
Rudi Gunawan
on 13 Jan 2016
Categories
Find more on Choose a Solver 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!