help-octave
[Top][All Lists]
Advanced

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

Re: solving set of inequalities


From: John W. Eaton
Subject: Re: solving set of inequalities
Date: Mon, 25 Jan 2010 13:31:49 -0500

On 25-Jan-2010, Petr Korviny wrote:

| As I mentioned above,

Above?  Your new text appeared as the first thing in the message I
received, and there was nothing above it.

 I need to find out solution of set of linear inequalities
| (to get values of variables x1,x2,x3,...) or to get an information of
| nonexistence any such solution.
| 
| At this picture:
| http://suzelly.opf.slu.cz/~korviny/zzz/octave/excel_solver.png
| you can see utilization of Excel's Solver add-in I used to get solution of
| viewed set. "alpha" variable is always set to a number <0;1>, so set of
| inequalities is linear.

Then why does your problem statement show you maximizing alpha and
that it has bounds of [0, 1]?

| Finding a solution for this set of linear inequalities is only one step in the
| process. I'd like to write it all as a script in Octave.
| 
| All tips and suggestions are welcome.  Thanks

The problem you show in the image is not just a "set of linear
inequalities".  It is a nonlinear optimization problem.  With some
rearrangement to get your problem statement into the form accepted by
Octave's sqp function, I obtain

  x =

     0.538461538452721
     0.307692307698186
     0.153846153849093
     0.749999999995322

  obj = -0.749999999995322

I included alpha as a fourth decision variable, and since you are
maximizing alpha but sqp minimizes it's objective function, I used
-alpha as the objective for sqp.  Here's teh code I used:

  x = [1; 1; 1; 1];

  function retval = phi (x)
    alpha = x(4);
    retval = -alpha;
  endfunction

  function retval = g (x)
    retval = x(1) + x(2) + x(3) - 1;
  endfunction

  function retval = h (x)
    alpha = x(4);
    retval = [x(1)-(1+alpha)*x(2);
              (3-alpha)*x(2)-x(1);
              x(1)-(2+alpha)*x(3);
              (5-2*alpha)*x(3)-x(1);
              x(2)-2*x(3);
              (3-alpha)*x(3)-x(2)];
  endfunction

  lb = [0; 0; 0; 0];
  ub = [1; realmax; realmax; realmax];

  [x, obj] = sqp (x, @phi, @g, @h, lb, ub)

jwe

-- 
A: Yes.
 > Q: Are you sure?
 >> A: Because it reverses the logical flow of conversation.
 >>> Q: Why is top posting annoying in email?



reply via email to

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