TomSym
≈ 2 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
The TomSym MATLAB symbolic modeling engine is a platform for modeling applied optimization and optimal control problems.
The TomSym MATLAB symbolic modeling engine is a platform for modeling applied optimization and optimal control problems. Multiplication by 1 or the identity matrix is eliminated: 1*A = A Addition/subtraction of 0 is eliminated: 0+A = A All-same matrices are reduced to scalars: [3;3;3]+x = 3+x Scalars are moved to the left in addition/subtraction: A-y = -y+A Inverse operations cancel: sqrt(x)^2 = x c = [-7; -5]; A = [ 1 2 4 1 ]; b_U = [ 6; 12 ]; x_L = [ 0; 0 ]; toms 2x1 x solution = ezsolve(c'*x, {A*x Name='minlp1Demo - Kocis/Grossman.'; toms 2x1 x toms 3x1 integer y objective = [2 3 1.5 2 -0.5]*[x;y]; constraints = { ... x(1) >= 0, ... x(2) >= 1e-8, ... x % Create the indices used in model i = tomArrayIdx('i', 1:6); j = tomArrayIdx('j', 1:6); k = tomArrayIdx('k', 1:6); l = tomArrayIdx('l', 1:6); % Create an integer variable of full length flow = tom('flow', 6^4, 1, 'int'); % Convert the variable to a matrix with four indices. flow = tomArray(flow,[6, 6, 6, 6]); % Create a constraint valid for all i and j cons = {sum(sum(flow(i, j, k, l), k), l) == 1}; % Create a scalar based on multi-index multiplications distance = tomArray([ 0 945 605 4667 4749 4394;... 945 0 866 3726 3806 3448;... 605 866 0 4471 4541 4152;... 4667 3726 4471 0 109 415;... 4749 3806 4541 109 0 431;... 4394 3448 4152 415 431 0]); sumtotal = sum(vec((distance(i, k) + distance(l, j)+... distance(k, l)*.8).*flow(i, j, k, l))); toms x1 x2 alpha = 100; % USE MAD (AUTOMATIC DIFFERENTIATION) FOR ONE FUNCTION % % Create a wrapper function. In this case we use sin, but it could be any % MAD supported function. y = wrap(struct('fun','sin','n',1,'sz1',1,'sz2',1,'JFuns','MAD'),x1/x2); f = alpha*(x2-x1^2)^2 + (1-x1)^2 + y; % Setup and solve the problem c = -x1^2 - x2; con = {-1000
Text derived from https://en.wikipedia.org/w/index.php?oldid=1209739546 under CC BY-SA 4.0; modifications have been made.