or-tools, CP SAT: usage of target of AddDivisionEquality in a goal function - or-tools

Dears,
is it possible to use the target value of AddDivisionEquality of CP SAT (or-tools) as variable to be maximized in a goal function?

of course. Any linear combination of variables is a valid objective function.

Related

Turing Logarithmic Function

I was wondering if Turing had a logarithmic function and what it was. If not, I was wondering how I could create my own logarithmic function without a table look up or brute force if it is possible. Thanks in advance.
Turns out there is no way to do it. Better off using brute force.
Actually there is a solution: Turing has natural log function. You can use base conversions to get log of other bases
EDIT: bass conversion:
function getlog:
6*log(6)=666
logcycle(6)
end function
function logcycle:
return getlog(logcycle(getlog(6))
end function

How can I get workspace variables in MATLAB Function?

I am using Matlab function in my simulink code where I am using the load command for getting some matrices and variables from the workspace
persistent ProblemParams;
if isempty(ProblemParams)
ProblemParams = load('ProblemParams.mat');
end
This is working well, however there can be problem when I am running multiple simulations at the same time, hence I would like to know what other options do I have to pass an array to this block from MATLAB workspace?
Whether or not the above works, it's not the right way to get data into the block. You should load the variable into the MATLAB Workspace prior to starting the simulation, then pass the variable into the MATLAB Function Block as a Parameter Argument.

How to define a variable without assign any value to it

vo is the upper limit of an integration expression and this is the variable that I want to predefine as a variable without value since it is the variable I am trying to solve for.
Everything else is defined.
%//a object's velocity is changing as a function of sine, the full cycle is 0=>speed=>0
vt=-((speed/2)*cos((2*pi/t0)*t)-(speed/2)))
%//integrate vt function so I can get distance which has given
distance=int(vt,t,0,t0)
%//the last step is I need to find how long does it takes the object to finish a full cycle of movement
time=solve(eqn,t0)
Try using the syms command in MATLAB. The syms is part of the symbolic math toolbox and you can predefine "variables" without explicitly solving for them. They form a part of the mathematics expression that you want.
Once you formulate the equation you want, you can use solve (as you have already used in your post) to solve the variable for you.

How to pass a symbolic equation to constraints when using fmincon

I have the following problem: When using fmincon I need to supply it with constraints. The constrain .M file looks like this:
function [c,ceq]=podmienky_L(qL)
global podmL zL
c=[podmL+0.0001-zL]
ceq=[];
zL is a constant while podmL is a symbolic variable that contains this expression:
(22.1*cos(qL(4))(sin(qL(3))(0.35*sin(qL(1))
When I try to run fmincon I get an error: User function returned a complex value when evaluated;
But when I replace the variable podmL with (22.1*cos(qL(4))(sin(qL(3))(0.35*sin(qL(1)) everything works fine.
The equation in podmL is supplied by another script and can wary from use to use and can attain hideous proportions, so it is very impractical for me to simply hardwrite it into the constraints function. Does anybody have any ideas?
Thanks

Getting the solver type and step size (for fixed step solvers)

we are trying to integrate a simulation model into Simulink as a block. We have a custom continuous block which loads an m file that contains the functions Derivatives, Outputs etc.
My question is: is there a way to find out which solver is used currently and with which parameters? Our model won't be able to support variable time solvers and I would like to give a warning. Similarly, the model requires the fixed step time for initialization.
Thanks in advance.
You can get the current solver name using
get_param('modelName', 'SolverName');
Some of the other common solver parameters are
AbsTol
FixedStep
InitialStep
ZcThreshold
ExtrapolationOrder
MaxStep
MinStep
RelTol
SolverMode
You can find other parameters you may wish to query by opening the .mdl file in your favorite text editor and digging through it.
If I'm understanding your use case correctly, you are trying to determine the type of solver (and other solver params) for the top-level simulink system containing your block.
I think the following should give you what you want:
get_param(bdroot, 'SolverType'); % //Returns 'Variable-step' or 'Fixed-step'
get_param(bdroot, 'FixedStep'); % //Returns the fixed step size
Notice that for purposes of generality/reusability, this uses bdroot to identify the top-level system (rather than explicitly specifying the name of this system).
If you want to find out more about other model parameters that you can get/set, I would check out this doc.
Additionally, I'm interested to know why it is that your model doesn't support a variable-step solver?