How to introduce a vector of dimension 60 in the syntax of toyprob.f

37 views
Skip to first unread message

jlcb

unread,
Apr 5, 2013, 9:06:58 PM4/5/13
to tango-...@googlegroups.com
Hello,

I'm new on FORTRAN so my doubt is concerning the syntax rather than ALGENCAN itself. My optimization problem consist on 50 variables and 60 constraints. Is there any efficient way to introducing the constraints as well as the gradient of each?(I already have those expressions in a text file in vector form). The following example works but when I try to define a vector "v" with a greater dimension I get an error message while compiling. I try using continuation line command, but it did not work. Thanks, jl


(.........ERROR MESSAGE....................)
toyprob.f:274.72:

      v =(/(-2*x(1)**3)/(1 + x(1)**2)**2+(2*x(1))/(1 + x(1)**2),2*x(2),2
                                                                        1
Error: Syntax error in array constructor at (1)


(......EXAMPLE THAT WORKS......)

C     ******************************************************************
C     FROM HERE ON YOU MUST MODIFY THE SUBROUTINE TO SET THE GRADIENT
C     VECTOR OF YOUR OBJECTIVE FUNCTION:
C     ******************************************************************

      flag = 0
      v =(/(-2*x(1)**3)/(1 + x(1)**2)**2+(2*x(1))/(1 + x(1)**2),2*x(2)/)

      do i = 1 , n
        g(i) = v(i)
      end do
....)

John Gardenghi

unread,
Apr 8, 2013, 6:12:09 PM4/8/13
to tango-...@googlegroups.com
Hello,

Thank you for using Algencan.

When you define v = (/(-2*x(1)**3)/(1 + x(1)**2)**2+(2*x(1))/(1 + x(1)**2),2*x(2)/), you are defining a vector of size 2 (each component is separated by a comma inside the (/ /) delimiters). If you change the dimension of v, you must change its initialization too.

It may be a good idea to post all the code that is throwing the error message you showed, thus we can identify where the error is.

You have a couple of options to program the constraints evaluation as well as their gradients. You can choose the way is more convenient to you. The file toyprob.f is the most basic example to follow, but it may not fit to you necessity depending on how the file you have is.

How the data is organized in your file? Do you have a vector for the constraints value? And what about the constraints jacobian, is it a dense matrix?

Regards,
John.
Reply all
Reply to author
Forward
0 new messages