[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Newbie question - sqp solver equality constraints function
From: |
alexegin |
Subject: |
Re: Newbie question - sqp solver equality constraints function |
Date: |
Thu, 22 Jun 2017 03:41:45 -0700 (PDT) |
Hi, *"Juan Pablo Carbajal-2"*<br/>
Juan Pablo Carbajal-2 wrote
> ... also try to avoid that I get your code in a single line, makes it hard
> to read
Sorry, I format my code using *pre* html tags - I am just trying to make it
easier to read and it looks fine in a browser. But if it makes it hard to
read I will not use HTML format.
I think I know what is the reason of the error - when I was checking
intitial guess as you sad I realized that it contains *positive values
only*. When at least one of the values is *negative* - everything runs
without any errors. I do not know yet how to avoid it, but *thank you very
much !!!*
Can I ask you one more time to help me with the Octave syntax - as far as
you can see I am not familiar with it
Here is my full script and I think *moo* function can be implemented in a
much more easier way - /simplified/, as you said:
clear all;
function r = moo( A, B )
Tmp = zeros( 1, rows( B ) ); # Temp matrix
Bt = B'; # Transpose B
# Fill in temp matrix
for i = 1:columns( Bt )
for j = 1:rows( A )
Tmp( 1, i ) += A( j, i ) * Bt( 1, j );
endfor
endfor
# Compute result
#r = 0;
#for i = 1:columns( Tmp )
# r = r + Tmp( 1, i ) * B( i, 1 );
#endfor
r = Tmp * B; # I think it is better, right?
endfunction
Y = dlmread( "y.csv", "\t" );
Yt = Y';
R = dlmread( "r.csv", "\t" );
Q = dlmread( "q.csv", "\t" );
f = dlmread( "f.csv", "\t" );
Lb = dlmread( "lb.csv", "\t" ); # -1.0
Ub = dlmread( "ub.csv", "\t" ); # 1.0
phi = @( x ) - Yt * x;
g = @( x ) [ sum( x( x < 0.0 ) ); sum( x( x >=0.0 ) ) ] - [ Lb; Ub ];
h = @( x ) f - moo( Q, x );
tic;
[x obj info iter nf l] = sqp( R, phi, g, h, Lb, Ub );
toc;
Thank you very much again - you helped me a lot!
--
View this message in context:
http://octave.1599824.n4.nabble.com/Newbie-question-sqp-solver-equality-constraints-function-tp4683834p4683861.html
Sent from the Octave - General mailing list archive at Nabble.com.
- Newbie question - sqp solver equality constraints function, alexegin, 2017/06/21
- Re: Newbie question - sqp solver equality constraints function, Juan Pablo Carbajal, 2017/06/21
- Re: Newbie question - sqp solver equality constraints function, alexegin, 2017/06/22
- Re: Newbie question - sqp solver equality constraints function, Juan Pablo Carbajal, 2017/06/22
- Re: Newbie question - sqp solver equality constraints function,
alexegin <=
- Re: Newbie question - sqp solver equality constraints function, Juan Pablo Carbajal, 2017/06/22
- Re: Newbie question - sqp solver equality constraints function, alexegin, 2017/06/22
- Re: Newbie question - sqp solver equality constraints function, Juan Pablo Carbajal, 2017/06/24
- Re: Newbie question - sqp solver equality constraints function, alexegin, 2017/06/29
- Re: Newbie question - sqp solver equality constraints function, Juan Pablo Carbajal, 2017/06/29
- Re: Newbie question - sqp solver equality constraints function, alexegin, 2017/06/29
- Re: Newbie question - sqp solver equality constraints function, Juan Pablo Carbajal, 2017/06/29
- Re: Newbie question - sqp solver equality constraints function, alexegin, 2017/06/29
- Re: Newbie question - sqp solver equality constraints function, Juan Pablo Carbajal, 2017/06/29