help-octave
[Top][All Lists]
Advanced

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

problems with sqp constraints?


From: fork
Subject: problems with sqp constraints?
Date: Mon, 16 Apr 2012 21:28:37 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

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)




reply via email to

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