Can anyone have a look over this .nb, as I am quite sure my set of 10 equations for 7 unknowns and 3 differentiated unknowns is valid? NDSolve returns nothing, it won't even give me an error message.
Link to notebook
Related
I am confused by not being able to solve this equation in Comsol
This is equation I mention:
1-2*sqrt(Lf/pi)*integrate((1)/sqrt(Lf^2-x^2)*(1+0.3*(1-x/Lf)/(1+Lf/0.1)),x,0,Lf)
If I write it in ODE and run, Comsol will notice message error (division by zero)
If I add eps right after like this (Lf^2 -x^2 +eps), Comsol runs ok but result I get absolutely wrong
Any idea about my problem ?
I have a large scale multi objective optimization problem to solve with fmincon solver of Matlab. I tried different solver to get a better and faster output. Here is the challenge:
I am getting Exit Flag: 1,0,4,5 for different Pareto points ,as it is a multi-objective optimization problem, with Active-set algorithm. Then I tried to check different algorithms like interior-point and sqp for generating the Pareto points. I observed that sqp returns few exit flags 1, some 2 and few 0 but not any 4 or 5 flag. Also, I should note that, its 0 and 2 flagged solutions are correct answers . However, When it comes to return any exit flag except 1, it takes a long time to solve the Pareto point.
As interior-point algorithm is designed for large scale program, it's very faster than sqp in generating the Pareto solutions. However, it only returns solutions with Exit flag 0. Unfortunately, its 0 flagged solutions are wrong solutions despite sqp which its 0 and 2 flagged solutions are correct answers.
0) Is there anyway to config the fmincon to solve my problem with interior-point and also get the correct solutions? In the literature I saw some problems similar to mine have been solved with interior-point algorithm.
1) Is there any settings (TolX,TolCon,...) that I can use to get more exit flag 1 ?
2) Is there any setting that speeds up the optimization process with the cost of lower accuracy?
3) For 2 Pareto points I am getting exit flag -2 , which means the problem is not feasible for them. It is expected from the nature of the problem. But it takes ages for fmincon to determine the Exit-Flag -2. Is there any option that I can set to satisfy 1,2 and also leave this infeasible point faster?
I couldn't do this , because I can only set options for one time and all Pareto points should use the same option.
To describe the problem I should say:
I have several linear and nonlinear (.^2,Sin...) for both equality and inequality constraints (about 300) and also having 400 optimization variables. All objective functions of this multi-objective optimization problem is linear.
these are the options that I currently use. Please help me to modify it
options = optimset('Algorithm', 'sqp', 'Display', 'off');
options = optimset('Algorithm', 'sqp', 'Display', 'off', 'TolX',1e-6,...
'TolFun',1e-6,'MaxIter',1e2, 'MaxFunEvals', 1e4);
First option takes about 500 sec for generating 15 Pareto points. Meaning that each optimization of fmincon expend 33 sec.
The second option takes 200 sec, which is 13 sec for each optimization of fmincon.
Your help will be highly appreciated.
I am trying to learn meta regression using the metafor() package. In running
one of the mixed regression models, I received an error indicating
"There are outcomes with non-positive sampling variances."
I am at lost as to how to proceed with this error. I understand that certain
model statistics (e.g., I^2 and QE) cannot be computed with due to the
presence of non-positive sampling variances. However, I am not sure whether
these results can be interpreted similarly as we would have otherwise. I
also tried using other estimators and/or the unweighted option; the error
still persists.
Any suggestions would be much appreciated.
First of all, to clarify: You are getting a warning, not an error.
Aside from that, I can't think of many situations where it is reasonable to assume that the sampling variance is really equal to 0 in a particular study. I would first question whether this really makes sense. This is why the rma() function is generating this warning message -- to make the user aware of this situation and question whether this really is intended/reasonable.
But suppose that we really want to go through with this, then you have to use an estimator for tau^2 that can handle this (e.g., method="REML" -- which is actually the default). If the estimate of tau^2 ends up equal to 0 as well, then the model cannot be fitted at all (due to division by zero -- and then you get an error). If you do end up with a positive estimate of tau^2, then the results should be okay (but things like the Q-test, I^2, or H^2 cannot be computed then).
I have defined an extended Euclidean algorithm in Maxima as
ext_euclid(a,b):=block(
[x,y,d,x_old,y_old,d_old],
if b = 0 then return([1,0,a])
else ([x_old,y_old,d_old]:ext_euclid(b,mod(a,b)),
[x,y,d]:[y_old,x_old-quotient(a,b)*y_old,d_old],
return([x,y,d])));
in order to solve linear Diophantine equations of the form a+b=c where gcd(a,b)=1, however if a-b=c I get -1 returned by the algorithm for the divisor but gcd(a,-b) as before. Is my algorithm wrong, or can it be used for a-b=c?
Iain
I don't quite understand what the problem is. Can you please give two examples, one in which the result matches what you expected, and one in which it doesn't (and please say what's your expected result in that case).
EDIT: OP replies: "to solve 5x+7y is 23 ext_euclid (5,7) returns [3,-2,1] where gcd(5,7) is 1 however for 5x-7y is 23 ext_euclid(5,-7) returns [-3,1,-1] but gcd(5,-7) is still 1 this fails Bezout's identity ax+by is gcd(a,b)"
Also if you are trying to implement a particular statement of the algorithm, can you please link to it or copy it here.
OP replies: "code at http://mvngu.wordpress.com/2009/08/25/elementary-number-theory-using-maxima/"
One possible thing to look at: does the mod function behave as you expect it?
OP replies: "mod(5,7) is, mod(5,-7) is -2"
I am studing the algorithm given here, and
somewhere it is claimed that it is efficent and always give correct result.
But, I try to run the algorithm and it is not giving me correct or efficent output for the following patterns.
For 5 x 5 grid, where (n) is light number and 0/1 state whethere the light is on/off, 1 ON and 0 OFF.
(1)1 (2)0 (3)0 (4)0 (5)0 the output should be 1,7,13,19,25(Pressing this light will make the full grid OFF. But what I am getting is this
(6)0 (7)1 (8)0 (9)0 (10)0 3,5,6,7,8,10,13,16,18,19,20,21,23.
(11)0 (12)0 (13)1 (14)0 (15)0
(16)0 (17)0 (18)0 (19)1 (20)0
(21)0 (22)0 (23)0 (24)0 (25)1
While for some pattern it is giving me correct output as below.
(1)0 (2)0 (3)0 (4)0 (5)1 the output should be 5,9,13,17,21, and the algorithm is giving me correct result.
(6)0 (7)0 (8)0 (9)1 (10)0
(11)0 (12)0 (13)1 (14)0 (15)0
(16)0 (17)1 (18)0 (19)0 (20)0
(21)1 (22)0 (23)0 (24)0 (25)0
If somebody need a code let me know I can post it.
Can please somebody let me know if this methods will always give correct as well as efficient result or not ?
(I'm the author of the code you linked to.) To the best of my knowledge, the code is correct (and I'm sure that the high-level algorithm of using Gaussian elimination over GF(2) is correct). The solution it produces is guaranteed to solve the puzzle, though it's not necessarily the minimal number of button presses. The "efficiency" I was referring to in the writeup refers to the time complexity of solving the puzzle overall (it can solve a Lights Out grid in polynomial time, as opposed to the exponential-time brute-force solution of trying all possible combinations) rather than to the "efficiency" of the generated solution.
I actually don't know any efficient algorithms for finding a solution requiring the minimum number of button presses. Let me know if you find one!
Hope this helps!