help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problems with sqp constraints?


From: Juan Pablo Carbajal
Subject: Re: problems with sqp constraints?
Date: Mon, 16 Apr 2012 23:43:03 +0200

On Mon, Apr 16, 2012 at 11:28 PM, fork <address@hidden> wrote:
> Hi,
>
> I got sqp to run with an entropy maximization set up (where the variables are
> probability values), but when I try to force the first moment to be too far 
> from
> the non-constrained first moment, I get a backtrace from sqp().  The error is
> right below, then the script is below that -- search for the words "THIS 
> WORKS"
> to bring you to the line that makes it fail at 0.2, but work ok at 0.1.
>
> Does anyone know why this might be happening? I don't *think* that inequality
> makes it infeasible, but maybe...  Maybe I am letting complex values creep in
> through the log functions and I either need abs() or another bound ... not
> sure...
>
>
> Octave error (full paths elided):
>
> error: octave_base_value::array_value(): wrong type argument `complex matrix'
> error: octave_base_value::int_value (): wrong type argument `scalar'
> error: __qp__: invalid arguments
> error: called from:
> error:   ... 3.6.1\m\optimization\qp.m at line 393, column 26
> error:   ... 3.6.1\m\optimization\sqp.m at line 414, column 32
> error:   ... sqp_experiments.m at line 47, column 35
>
>
>
> My script (don't make fun if my math is bad... ;) ):
>
> 1;
>
> ## ##############################
> ## negative entropy function and gradient
> ## ##############################
> function H = entr(p)
>    p = p(:);
>    _h = (p .* log10(p));
>    _pm = (p == 0);
>    h = ifelse(_pm, 0, _h);
>    H = sum(h);
> endfunction
>
> function dh = entr_gr(p)
>    dh = log(p) +1;
> endfunction
>
>
> ## ##############################
> ## handle equality constr
> ## ##############################
> function f = mk_g (A, b)
>    f = @(x) (A*x - b);
> endfunction;
>
> val = -1:.1:1;
> clear A b;
> A(1,:)  = ones(1, length(val));
> b(1,1)  = 1;
> A(2,:)  = val;
> b(2,1)  = 0.2;  ## THIS WORKS IF 0.1 or 0.0 !
>
> g = mk_g(A, b);
>
> ## ##############################
> ## do everything
> ## ##############################
>
>
> x0 = repmat(.01, length(val), 1);
> lb = repmat(  0, length(val), 1);
> ub = repmat(  1, length(val), 1);
>
> [x, obj, info, iter, nf, lambda] =   \
>       sqp (x0, address@hidden, @entr_gr}, g, [], lb, ub)
>
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave

Hi,
I do not know what is your problem, but you have to check that every
time qp is called the problem has to be feasible. Otherwise qp gets
matrices that make it fail, is usual to get an empty vector of
eigenvalues.
Maybe this thread helps you tracing the problem
http://octave.1599824.n4.nabble.com/Re-Core-function-SQP-td3709438.html


-- 
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]