This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
optimization [2018/09/18 10:35] mark.naves |
optimization [2022/01/12 13:41] jan.dejong |
||
---|---|---|---|
Line 6: | Line 6: | ||
<code matlab run_sim.m> | <code matlab run_sim.m> | ||
- | function cost = run_sim(P, Silent)% EXAMPLE SCRIPT FOR RUNNING SPACAR LIGHT | + | function |
if nargin == 1 | if nargin == 1 | ||
Silent = true; %run in silent mode when called by optimizer | Silent = true; %run in silent mode when called by optimizer | ||
Line 60: | Line 60: | ||
eprops(1).orien | eprops(1).orien | ||
eprops(1).nbeams | eprops(1).nbeams | ||
- | eprops(1).flex | + | eprops(1).flex |
eprops(1).color | eprops(1).color | ||
eprops(1).opacity | eprops(1).opacity | ||
Line 99: | Line 99: | ||
</ | </ | ||
- | An example to conduct the optimization is provided below, taking into account additional boundary conditions on the design parameters of the cross-hinge. See matlab' | + | An example to conduct the optimization is provided below, taking into account additional boundary conditions on the design parameters of the cross-hinge. See matlab' |
<code matlab optimization.m> | <code matlab optimization.m> | ||
Line 106: | Line 106: | ||
%starting point | %starting point | ||
- | x0 = [0.1 0.1 50e-3 0.2e-3]'; | + | x0 = [0.1; |
%constraints | %constraints | ||
- | A = [diag([1 1 1 1]); diag([-1 -1 -1 -1])]; | + | b1 = [0.05; 0.05; 25e-3; 0.1e-3]; % Lower bound (b1 < x) |
- | b = [0.2 0.2 75e-3 1e-3 0.05 0.05 25e-3 0.1e-3]'; | + | b2 = [0.2; |
+ | |||
+ | A = [-eye(4); eye(4)]; | ||
+ | b = [-b1;b2]; | ||
%optimization | %optimization | ||
Line 116: | Line 119: | ||
%show results | %show results | ||
- | run_sim(x_opt, | + | [cost, out] = run_sim(x_opt, |
</ | </ | ||
//Note: prescribing input rotation is only supported for SPACAR light version 1.27 or higher.// | //Note: prescribing input rotation is only supported for SPACAR light version 1.27 or higher.// |