Changeset 1634


Ignore:
Timestamp:
Jan 24, 2010 3:44:17 AM (10 years ago)
Author:
bradbell
Message:

/home/bradbell/cppad/trunk: Improve organization, documentation and speed up cppad_ipopt_nlp.

configure: changes corresponding to change in configure.ac.
check_doxygen.sh: check new souce files.
*/makefile.in: transfer changes in corresponding makefile.am.
test/makefile.am: convert to using ipopt_cppad library.
speed/makefile.am: do not use library because need optimized code.
cppad_ipopt_nlp.*: split out and simplify more operations in separate files.
example/makefile.am: convert to using ipopt_cppad library.
src/makefile.am: convert to using ipopt_cppad library.
configure.ac: include makefile for new library.
build.sh: code for libtool (but commented out).
makefile.am: add src directory to build list.
whats_new_10.omh: changes from users point of view.

jac_g_map.hpp: mapping from (i,j) to Ipopt index split from cppad_ipopt_nlp.
hes_fg_map.hpp: mapping from (i,j) to Ipopt index split from cppad_ipopt_nlp.
makefile.am: build library.
vec_fun_pattern.hpp: compute sparsity patterns split form cppad_ipopt_nlp.

Location:
trunk
Files:
8 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/build.sh

    r1633 r1634  
    142142        # automatically change version for certain files
    143143        # (the [.0-9]* is for using build.sh in CppAD/stable/* directories)
     144        #
     145        # libtool does not seem to support version by date
     146        # sed < cppad_ipopt/src/makefile.am > cppad_ipopt/src/makefile.am.$$ \
     147        #       -e "s/\(-version-info\) *[0-9]\{8\}[.0-9]*/\1 $yyyymmdd/"
    144148        sed < AUTHORS > AUTHORS.$$ \
    145149                -e "s/, [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\} *,/, $yyyy_mm_dd,/"
     
    164168                configure
    165169                cppad/config.h
     170                cppad_ipopt/src/makefile.am
    166171        "
    167172        for name in $list
     
    190195                -e '/END AC_CONFIG_FILES/,$d' \
    191196                -e '1,/AC_CONFIG_FILES/d' \
    192                 -e 's/makefile/&.in/' \
    193                 -e 's/^[ \t]*//' \
    194                 -e '/makefile/p'`
     197                -e 's|/makefile$|&.in|' \
     198                -e '/\/makefile.in/p'`
    195199        auto_output="
    196200                depcomp
     
    229233                exit 1
    230234        fi
     235        #
     236        echo "skipping libtoolize"
     237        # echo "libtoolize -c -f -i"
     238        # if ! libtoolize -c -f -i
     239        # then
     240        #       exit 1
     241        # fi
    231242        #
    232243        echo "autoconf"
  • trunk/check_doxygen.sh

    r1632 r1634  
    7373        sinh_op.hpp
    7474        sparse_binary_op.hpp
    75         sparse_map2vec.cpp
    7675        sparse_map2vec.hpp
    7776        sparse_unary_op.hpp
     
    8382        sparse_pack.hpp
    8483        sparse_set.hpp
     84
     85        hes_fg_map.cpp
     86        jac_g_map.cpp
     87        sparse_map2vec.cpp
     88        vec_fun_pattern.cpp
    8589"
    8690# --------------------------------------------------------------------------
  • trunk/configure

    r1633 r1634  
    40204020
    40214021
     4022
    40224023if test -n "$ac_tool_prefix"; then
    40234024  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
     
    56885689
    56895690
    5690 ac_config_files="$ac_config_files cppad/configure.hpp doxyfile doc.omh example/test_one.sh omh/install_unix.omh omh/install_windows.omh test_more/test_one.sh makefile example/makefile cppad_ipopt/example/makefile cppad_ipopt/speed/makefile cppad_ipopt/test/makefile introduction/get_started/makefile introduction/exp_apx/makefile print_for/makefile speed/adolc/makefile speed/cppad/makefile speed/double/makefile speed/example/makefile speed/fadbad/makefile speed/profile/makefile speed/sacado/makefile test_more/makefile"
     5691ac_config_files="$ac_config_files cppad/configure.hpp doxyfile doc.omh example/test_one.sh omh/install_unix.omh omh/install_windows.omh test_more/test_one.sh makefile example/makefile cppad_ipopt/src/makefile cppad_ipopt/example/makefile cppad_ipopt/speed/makefile cppad_ipopt/test/makefile introduction/get_started/makefile introduction/exp_apx/makefile print_for/makefile speed/adolc/makefile speed/cppad/makefile speed/double/makefile speed/example/makefile speed/fadbad/makefile speed/profile/makefile speed/sacado/makefile test_more/makefile"
    56915692
    56925693ac_config_commands="$ac_config_commands default-1"
     
    64416442    "makefile") CONFIG_FILES="$CONFIG_FILES makefile" ;;
    64426443    "example/makefile") CONFIG_FILES="$CONFIG_FILES example/makefile" ;;
     6444    "cppad_ipopt/src/makefile") CONFIG_FILES="$CONFIG_FILES cppad_ipopt/src/makefile" ;;
    64436445    "cppad_ipopt/example/makefile") CONFIG_FILES="$CONFIG_FILES cppad_ipopt/example/makefile" ;;
    64446446    "cppad_ipopt/speed/makefile") CONFIG_FILES="$CONFIG_FILES cppad_ipopt/speed/makefile" ;;
  • trunk/configure.ac

    r1633 r1634  
    251251AM_INIT_AUTOMAKE(nostdinc)
    252252
     253dnl Use LIBTOOL for cppad_ipopt ?
     254dnl AC_PROG_LIBTOOL
     255
    253256dnl Determine if ranlib is present and where it is if present (set RANLIB)
    254257AC_PROG_RANLIB
     
    313316        makefile
    314317        example/makefile
     318        cppad_ipopt/src/makefile
    315319        cppad_ipopt/example/makefile
    316320        cppad_ipopt/speed/makefile
  • trunk/cppad_ipopt/example/makefile.am

    r1632 r1634  
    3838                     -I$(IPOPT_DIR)/include
    3939#
    40 LDADD             = -lipopt $(FCLIBS) $(PTHREAD_LIB) $(DL_LIB)
    41 AM_LDFLAGS        = -L$(IPOPT_DIR)/lib
     40LDADD             = -lcppad_ipopt -lipopt $(FCLIBS) $(PTHREAD_LIB) $(DL_LIB)
     41AM_LDFLAGS        = -L../src -L$(IPOPT_DIR)/lib
    4242#
    4343example_SOURCES   = \
    4444        example.cpp \
    45         ../src/cppad_ipopt_nlp.cpp \
    46         ../src/cppad_ipopt_nlp.hpp \
    47         ../src/sparse_map2vec.cpp \
    48         ../src/sparse_map2vec.hpp \
    4945        get_started.cpp \
    5046        ode_fast.hpp \
  • trunk/cppad_ipopt/example/makefile.in

    r1633 r1634  
    4545CONFIG_CLEAN_VPATH_FILES =
    4646PROGRAMS = $(noinst_PROGRAMS)
    47 am_example_OBJECTS = example.$(OBJEXT) cppad_ipopt_nlp.$(OBJEXT) \
    48         sparse_map2vec.$(OBJEXT) get_started.$(OBJEXT) \
     47am_example_OBJECTS = example.$(OBJEXT) get_started.$(OBJEXT) \
    4948        ode_check.$(OBJEXT)
    5049example_OBJECTS = $(am_example_OBJECTS)
     
    209208
    210209#
    211 LDADD = -lipopt $(FCLIBS) $(PTHREAD_LIB) $(DL_LIB)
    212 AM_LDFLAGS = -L$(IPOPT_DIR)/lib
     210LDADD = -lcppad_ipopt -lipopt $(FCLIBS) $(PTHREAD_LIB) $(DL_LIB)
     211AM_LDFLAGS = -L../src -L$(IPOPT_DIR)/lib
    213212#
    214213example_SOURCES = \
    215214        example.cpp \
    216         ../src/cppad_ipopt_nlp.cpp \
    217         ../src/cppad_ipopt_nlp.hpp \
    218         ../src/sparse_map2vec.cpp \
    219         ../src/sparse_map2vec.hpp \
    220215        get_started.cpp \
    221216        ode_fast.hpp \
     
    272267        -rm -f *.tab.c
    273268
    274 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppad_ipopt_nlp.Po@am__quote@
    275269@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/example.Po@am__quote@
    276270@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_started.Po@am__quote@
    277271@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_check.Po@am__quote@
    278 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_map2vec.Po@am__quote@
    279272
    280273.cpp.o:
     
    291284@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    292285@am__fastdepCXX_FALSE@  $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
    293 
    294 cppad_ipopt_nlp.o: ../src/cppad_ipopt_nlp.cpp
    295 @am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT cppad_ipopt_nlp.o -MD -MP -MF $(DEPDIR)/cppad_ipopt_nlp.Tpo -c -o cppad_ipopt_nlp.o `test -f '../src/cppad_ipopt_nlp.cpp' || echo '$(srcdir)/'`../src/cppad_ipopt_nlp.cpp
    296 @am__fastdepCXX_TRUE@   $(am__mv) $(DEPDIR)/cppad_ipopt_nlp.Tpo $(DEPDIR)/cppad_ipopt_nlp.Po
    297 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../src/cppad_ipopt_nlp.cpp' object='cppad_ipopt_nlp.o' libtool=no @AMDEPBACKSLASH@
    298 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    299 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o cppad_ipopt_nlp.o `test -f '../src/cppad_ipopt_nlp.cpp' || echo '$(srcdir)/'`../src/cppad_ipopt_nlp.cpp
    300 
    301 cppad_ipopt_nlp.obj: ../src/cppad_ipopt_nlp.cpp
    302 @am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT cppad_ipopt_nlp.obj -MD -MP -MF $(DEPDIR)/cppad_ipopt_nlp.Tpo -c -o cppad_ipopt_nlp.obj `if test -f '../src/cppad_ipopt_nlp.cpp'; then $(CYGPATH_W) '../src/cppad_ipopt_nlp.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/cppad_ipopt_nlp.cpp'; fi`
    303 @am__fastdepCXX_TRUE@   $(am__mv) $(DEPDIR)/cppad_ipopt_nlp.Tpo $(DEPDIR)/cppad_ipopt_nlp.Po
    304 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../src/cppad_ipopt_nlp.cpp' object='cppad_ipopt_nlp.obj' libtool=no @AMDEPBACKSLASH@
    305 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    306 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o cppad_ipopt_nlp.obj `if test -f '../src/cppad_ipopt_nlp.cpp'; then $(CYGPATH_W) '../src/cppad_ipopt_nlp.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/cppad_ipopt_nlp.cpp'; fi`
    307 
    308 sparse_map2vec.o: ../src/sparse_map2vec.cpp
    309 @am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sparse_map2vec.o -MD -MP -MF $(DEPDIR)/sparse_map2vec.Tpo -c -o sparse_map2vec.o `test -f '../src/sparse_map2vec.cpp' || echo '$(srcdir)/'`../src/sparse_map2vec.cpp
    310 @am__fastdepCXX_TRUE@   $(am__mv) $(DEPDIR)/sparse_map2vec.Tpo $(DEPDIR)/sparse_map2vec.Po
    311 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../src/sparse_map2vec.cpp' object='sparse_map2vec.o' libtool=no @AMDEPBACKSLASH@
    312 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    313 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sparse_map2vec.o `test -f '../src/sparse_map2vec.cpp' || echo '$(srcdir)/'`../src/sparse_map2vec.cpp
    314 
    315 sparse_map2vec.obj: ../src/sparse_map2vec.cpp
    316 @am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sparse_map2vec.obj -MD -MP -MF $(DEPDIR)/sparse_map2vec.Tpo -c -o sparse_map2vec.obj `if test -f '../src/sparse_map2vec.cpp'; then $(CYGPATH_W) '../src/sparse_map2vec.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/sparse_map2vec.cpp'; fi`
    317 @am__fastdepCXX_TRUE@   $(am__mv) $(DEPDIR)/sparse_map2vec.Tpo $(DEPDIR)/sparse_map2vec.Po
    318 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../src/sparse_map2vec.cpp' object='sparse_map2vec.obj' libtool=no @AMDEPBACKSLASH@
    319 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    320 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sparse_map2vec.obj `if test -f '../src/sparse_map2vec.cpp'; then $(CYGPATH_W) '../src/sparse_map2vec.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/sparse_map2vec.cpp'; fi`
    321286
    322287ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
  • trunk/cppad_ipopt/speed/makefile.am

    r1632 r1634  
    3333AM_LDFLAGS        = -L$(IPOPT_DIR)/lib
    3434#
     35# Cannot use ../src/libcppad_ipopt.a becasue it is compiled for debugging
     36# so build an optimized version here to use here.
    3537speed_SOURCES   = \
    3638        speed.cpp \
    37         ode_speed.cpp \
    3839        ../src/cppad_ipopt_nlp.cpp \
    39         ../src/cppad_ipopt_nlp.hpp \
     40        ../src/hes_fg_map.cpp \
     41        ../src/jac_g_map.cpp \
    4042        ../src/sparse_map2vec.cpp \
    41         ../src/sparse_map2vec.hpp \
    42         ../example/ode_fast.hpp \
    43         ../example/ode_problem.hpp \
    44         ../example/ode_simple.hpp 
     43        ../src/vec_fun_pattern.cpp \
     44        ode_speed.cpp
  • trunk/cppad_ipopt/speed/makefile.in

    r1633 r1634  
    4545CONFIG_CLEAN_VPATH_FILES =
    4646PROGRAMS = $(noinst_PROGRAMS)
    47 am_speed_OBJECTS = speed.$(OBJEXT) ode_speed.$(OBJEXT) \
    48         cppad_ipopt_nlp.$(OBJEXT) sparse_map2vec.$(OBJEXT)
     47am_speed_OBJECTS = speed.$(OBJEXT) cppad_ipopt_nlp.$(OBJEXT) \
     48        hes_fg_map.$(OBJEXT) jac_g_map.$(OBJEXT) \
     49        sparse_map2vec.$(OBJEXT) vec_fun_pattern.$(OBJEXT) \
     50        ode_speed.$(OBJEXT)
    4951speed_OBJECTS = $(am_speed_OBJECTS)
    5052speed_LDADD = $(LDADD)
     
    6163CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
    6264        -o $@
    63 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
    64         $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
    65 CCLD = $(CC)
    66 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
    6765SOURCES = $(speed_SOURCES)
    6866DIST_SOURCES = $(speed_SOURCES)
     
    202200AM_LDFLAGS = -L$(IPOPT_DIR)/lib
    203201#
     202# Cannot use ../src/libcppad_ipopt.a becasue it is compiled for debugging
     203# so build an optimized version here to use here.
    204204speed_SOURCES = \
    205205        speed.cpp \
    206         ode_speed.cpp \
    207206        ../src/cppad_ipopt_nlp.cpp \
    208         ../src/cppad_ipopt_nlp.hpp \
     207        ../src/hes_fg_map.cpp \
     208        ../src/jac_g_map.cpp \
    209209        ../src/sparse_map2vec.cpp \
    210         ../src/sparse_map2vec.hpp \
    211         ../example/ode_fast.hpp \
    212         ../example/ode_problem.hpp \
    213         ../example/ode_simple.hpp 
     210        ../src/vec_fun_pattern.cpp \
     211        ode_speed.cpp
    214212
    215213all: all-am
     
    261259
    262260@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppad_ipopt_nlp.Po@am__quote@
     261@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hes_fg_map.Po@am__quote@
     262@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jac_g_map.Po@am__quote@
    263263@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_speed.Po@am__quote@
    264264@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_map2vec.Po@am__quote@
    265265@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/speed.Po@am__quote@
     266@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vec_fun_pattern.Po@am__quote@
    266267
    267268.cpp.o:
     
    293294@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o cppad_ipopt_nlp.obj `if test -f '../src/cppad_ipopt_nlp.cpp'; then $(CYGPATH_W) '../src/cppad_ipopt_nlp.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/cppad_ipopt_nlp.cpp'; fi`
    294295
     296hes_fg_map.o: ../src/hes_fg_map.cpp
     297@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT hes_fg_map.o -MD -MP -MF $(DEPDIR)/hes_fg_map.Tpo -c -o hes_fg_map.o `test -f '../src/hes_fg_map.cpp' || echo '$(srcdir)/'`../src/hes_fg_map.cpp
     298@am__fastdepCXX_TRUE@   $(am__mv) $(DEPDIR)/hes_fg_map.Tpo $(DEPDIR)/hes_fg_map.Po
     299@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../src/hes_fg_map.cpp' object='hes_fg_map.o' libtool=no @AMDEPBACKSLASH@
     300@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     301@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o hes_fg_map.o `test -f '../src/hes_fg_map.cpp' || echo '$(srcdir)/'`../src/hes_fg_map.cpp
     302
     303hes_fg_map.obj: ../src/hes_fg_map.cpp
     304@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT hes_fg_map.obj -MD -MP -MF $(DEPDIR)/hes_fg_map.Tpo -c -o hes_fg_map.obj `if test -f '../src/hes_fg_map.cpp'; then $(CYGPATH_W) '../src/hes_fg_map.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/hes_fg_map.cpp'; fi`
     305@am__fastdepCXX_TRUE@   $(am__mv) $(DEPDIR)/hes_fg_map.Tpo $(DEPDIR)/hes_fg_map.Po
     306@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../src/hes_fg_map.cpp' object='hes_fg_map.obj' libtool=no @AMDEPBACKSLASH@
     307@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     308@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o hes_fg_map.obj `if test -f '../src/hes_fg_map.cpp'; then $(CYGPATH_W) '../src/hes_fg_map.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/hes_fg_map.cpp'; fi`
     309
     310jac_g_map.o: ../src/jac_g_map.cpp
     311@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT jac_g_map.o -MD -MP -MF $(DEPDIR)/jac_g_map.Tpo -c -o jac_g_map.o `test -f '../src/jac_g_map.cpp' || echo '$(srcdir)/'`../src/jac_g_map.cpp
     312@am__fastdepCXX_TRUE@   $(am__mv) $(DEPDIR)/jac_g_map.Tpo $(DEPDIR)/jac_g_map.Po
     313@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../src/jac_g_map.cpp' object='jac_g_map.o' libtool=no @AMDEPBACKSLASH@
     314@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     315@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o jac_g_map.o `test -f '../src/jac_g_map.cpp' || echo '$(srcdir)/'`../src/jac_g_map.cpp
     316
     317jac_g_map.obj: ../src/jac_g_map.cpp
     318@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT jac_g_map.obj -MD -MP -MF $(DEPDIR)/jac_g_map.Tpo -c -o jac_g_map.obj `if test -f '../src/jac_g_map.cpp'; then $(CYGPATH_W) '../src/jac_g_map.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/jac_g_map.cpp'; fi`
     319@am__fastdepCXX_TRUE@   $(am__mv) $(DEPDIR)/jac_g_map.Tpo $(DEPDIR)/jac_g_map.Po
     320@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../src/jac_g_map.cpp' object='jac_g_map.obj' libtool=no @AMDEPBACKSLASH@
     321@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     322@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o jac_g_map.obj `if test -f '../src/jac_g_map.cpp'; then $(CYGPATH_W) '../src/jac_g_map.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/jac_g_map.cpp'; fi`
     323
    295324sparse_map2vec.o: ../src/sparse_map2vec.cpp
    296325@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sparse_map2vec.o -MD -MP -MF $(DEPDIR)/sparse_map2vec.Tpo -c -o sparse_map2vec.o `test -f '../src/sparse_map2vec.cpp' || echo '$(srcdir)/'`../src/sparse_map2vec.cpp
     
    306335@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    307336@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sparse_map2vec.obj `if test -f '../src/sparse_map2vec.cpp'; then $(CYGPATH_W) '../src/sparse_map2vec.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/sparse_map2vec.cpp'; fi`
     337
     338vec_fun_pattern.o: ../src/vec_fun_pattern.cpp
     339@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT vec_fun_pattern.o -MD -MP -MF $(DEPDIR)/vec_fun_pattern.Tpo -c -o vec_fun_pattern.o `test -f '../src/vec_fun_pattern.cpp' || echo '$(srcdir)/'`../src/vec_fun_pattern.cpp
     340@am__fastdepCXX_TRUE@   $(am__mv) $(DEPDIR)/vec_fun_pattern.Tpo $(DEPDIR)/vec_fun_pattern.Po
     341@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../src/vec_fun_pattern.cpp' object='vec_fun_pattern.o' libtool=no @AMDEPBACKSLASH@
     342@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     343@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o vec_fun_pattern.o `test -f '../src/vec_fun_pattern.cpp' || echo '$(srcdir)/'`../src/vec_fun_pattern.cpp
     344
     345vec_fun_pattern.obj: ../src/vec_fun_pattern.cpp
     346@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT vec_fun_pattern.obj -MD -MP -MF $(DEPDIR)/vec_fun_pattern.Tpo -c -o vec_fun_pattern.obj `if test -f '../src/vec_fun_pattern.cpp'; then $(CYGPATH_W) '../src/vec_fun_pattern.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/vec_fun_pattern.cpp'; fi`
     347@am__fastdepCXX_TRUE@   $(am__mv) $(DEPDIR)/vec_fun_pattern.Tpo $(DEPDIR)/vec_fun_pattern.Po
     348@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../src/vec_fun_pattern.cpp' object='vec_fun_pattern.obj' libtool=no @AMDEPBACKSLASH@
     349@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     350@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o vec_fun_pattern.obj `if test -f '../src/vec_fun_pattern.cpp'; then $(CYGPATH_W) '../src/vec_fun_pattern.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/vec_fun_pattern.cpp'; fi`
    308351
    309352ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
  • trunk/cppad_ipopt/src/cppad_ipopt_nlp.cpp

    r1633 r1634  
    1212# include "cppad_ipopt_nlp.hpp"
    1313# include "sparse_map2vec.hpp"
     14# include "jac_g_map.hpp"
     15# include "hes_fg_map.hpp"
     16# include "vec_fun_pattern.hpp"
    1417
    1518// define as 0 for false or 1 for true
     
    4043          fg_info_ ( fg_info ) ,
    4144          solution_ (solution)
    42 {       size_t i, j, k;
     45{       size_t j, k;
    4346
    4447        // set information needed in cppad_ipopt_fg_info
     
    5760        size_t max_p      = 0;
    5861        size_t max_q      = 0;
    59         bool   retape_any = false;
    6062        for(k = 0; k < K_; k++)
    6163        {       L_[k]       = fg_info->number_terms(k);
     
    6567                max_p       = std::max(max_p, p_[k]);
    6668                max_q       = std::max(max_q, q_[k]);
    67                 retape_any |= retape_[k];
    6869                pattern_jac_r_[k].resize( p_[k] * q_[k] );
    6970                pattern_r_lag_[k].resize( q_[k] * q_[k] );
     
    7273        J_.resize(max_q);
    7374# ifndef NDEBUG
    74         size_t ell;
     75        size_t i, ell;
    7576        // check for valid range and domain indices
    7677        for(k = 0; k < K_; k++) for(ell = 0; ell < L_[k]; ell++)
     
    9798        }
    9899# endif
     100        // record r[k] for functions that do not need retaping
    99101        for(k = 0; k < K_; k++) if( ! retape_[k] )
    100102        {       // Record r_k (u): operation sequence does not depend on value
     
    109111                );
    110112        }
    111         if ( retape_any )
    112         {       // true sparsity pattern valid for all x is unknown
    113                 BoolVector pattern_jac_fg((m+1) * n);
    114                 for(i = 0; i <= m; i++)
    115                 {       for(j = 0; j < n; j++)
    116                                 pattern_jac_fg[i * n + j] = true;
    117                 }
    118                 compute_index_jac_g(m, n, pattern_jac_fg, index_jac_g_);
    119                 //
    120                 BoolVector pattern_h_lag(n * n);
    121                 for(j = 0; j < n; j++)
    122                 {       for(k = 0; k < n; k++)
    123                                 pattern_h_lag[j * n + k] = true;
    124                 }
    125                 compute_index_h_lag(m, n, pattern_h_lag, index_h_lag_);
    126         }
    127         else
    128         {       // compute index map for Jacobian of g
    129                 compute_index_jac_g(
    130                 fg_info_, I_, J_, K_, L_, m_, n_, p_, q_, r_fun_,   // inputs
    131                 pattern_jac_r_, index_jac_g_                        // outputs
    132                 );
    133 
    134                 // compute index map for Hessian of Lagragian
    135                 compute_index_h_lag(
    136                 fg_info_, I_, J_, K_, L_, m_, n_, p_, q_, r_fun_,   // inputs
    137                 pattern_r_lag_, index_h_lag_                        // outputs
    138                 );
    139         }
    140 
     113
     114        // compute a sparsity patterns for each r_k (u)
     115        vec_fun_pattern(
     116                K_, p_, q_, retape_, r_fun_,      // inputs
     117                pattern_jac_r_, pattern_r_lag_    // outputs
     118        );
     119
     120        // mapping from (i,j) to Ipopt sparsity index for Jacobian of g
     121        jac_g_map(
     122                fg_info_, m_, n_, K_, L_, p_, q_, pattern_jac_r_,   // inputs
     123                I_, J_,                                             // work
     124                index_jac_g_                                        // outputs
     125        );
     126
     127        // mapping from (i,j) to Ipopt sparsity index for Hessian of Lagragian
     128        hes_fg_map(
     129                fg_info_, m_, n_, K_, L_, p_, q_, pattern_r_lag_,   // inputs
     130                I_, J_,                                             // work
     131                index_hes_fg_                                       // outputs
     132        );
     133       
    141134        // Compute Ipopt sparsity structure for Jacobian of g
    142135        sparse_map2vec(
     
    147140        // Compute Ipopt sparsity structure for Hessian of Lagragian
    148141        sparse_map2vec(
    149                 index_h_lag_,                         // inputs
     142                index_hes_fg_,                        // inputs
    150143                nnz_h_lag_, iRow_h_lag_, jCol_h_lag_  // outputs
    151144        );
     
    195188        // stop the recording and store operation sequence in r_fun
    196189        r_fun[k].Dependent(u_ad, r_ad);
    197 }
    198 
    199 // static member function that computes CppAD sparsity pattern for
    200 // Jacobian of g
    201 void cppad_ipopt_nlp::compute_index_jac_g(
    202         cppad_ipopt_fg_info*  fg_info        ,
    203         SizeVector&           I              ,
    204         SizeVector&           J              ,
    205         size_t                K              ,
    206         SizeVector&           L              ,
    207         size_t                m              ,
    208         size_t                n              ,
    209         SizeVector&           p              ,
    210         SizeVector&           q              ,
    211         ADFunVector&          r_fun          ,
    212         BoolVectorVector&     pattern_jac_r  ,
    213         IndexMap&             index_jac_g    )
    214 /*
    215 fg_info: input
    216 the cppad_ipopt_fg_info object that is used to compute
    217 information about the representation of fg(x).
    218 
    219 I: scratch space
    220 Vector of length greater than or equal p[k] for all k.
    221 
    222 J: scratch space
    223 Vector of length greatern than or equal q[k] for all k.
    224 
    225 K: input
    226 Number of functions in the representation for fg(x) in terms of r_k (u).
    227 
    228 L: input
    229 L[k] is the number of terms, in the representaiton for fg(x), that use r_k (u).
    230 
    231 m: input
    232 The number of components in the constraint function g.
    233 
    234 n: input
    235 Number of indpendent variables.
    236 
    237 p: input
    238 for k = 0 , ... , K-1,
    239 p[k] is dimension of the range space for r_k (u).
    240 
    241 q: input
    242 for k = 0 , ... , K-1,
    243 p[k] is dimension of the domain space for r_k (u).
    244 
    245 r_fun: input
    246 for k = 0 , ... , K-1,
    247 r_fun[k] is the CppAD function object that is used to compute
    248 the sparsity patterns for r_k (u).
    249 The state of these objects actually changes because some forward mode
    250 routines are used.
    251 The operation sequence correspopnding to these object do not change.
    252 
    253 pattern_jac_r: output
    254 For k = 0 , ... , K-1,
    255 on input pattern_jac_r[k], this must be a vector of length p[k] * q[k].
    256 On output it is the CppAD sparsity pattern for the Jacobian of r_k (u).
    257 
    258 index_jac_g:
    259 On input, this is empty; i.e., index_jac_g.size() == 0.
    260 On output, it is the index mapping from (i, j) in the Jacobian of g
    261 to the corresponding values array index in Ipopt.
    262 Furthermore, if index_jac_g[i].find(j) == index_jac_g[i].end(),
    263 then the (i, j) entry in the Jacobian of g is always zero.
    264 */
    265 {
    266         size_t i, j, k, ell, ir, ifg;
    267 
    268         for(k = 0; k < K; k++)
    269         {       // compute sparsity pattern for r_k (u)
    270                 CPPAD_ASSERT_UNKNOWN( pattern_jac_r[k].size() == p[k] * q[k] );
    271                 CPPAD_ASSERT_UNKNOWN( r_fun[k].Range() == p[k] );
    272                 CPPAD_ASSERT_UNKNOWN( r_fun[k].Domain() == q[k] );
    273                 if( q[k] < p[k] )
    274                 {       // use forward mode
    275                         BoolVector pattern_domain(q[k] * q[k]);
    276                         for(i = 0; i < q[k]; i++)
    277                         {       for(j = 0; j < q[k]; j++)
    278                                         pattern_domain[i * q[k] + j] = false;
    279                                 pattern_domain[i * q[k] + i] = true;
    280                         }
    281                         pattern_jac_r[k] =
    282                                 r_fun[k].ForSparseJac(q[k], pattern_domain);
    283                 }
    284                 else
    285                 {       // use reverse mode
    286                         BoolVector pattern_range(p[k] * p[k]);
    287                         for(i = 0; i < p[k]; i++)
    288                         {       for(j = 0; j < p[k]; j++)
    289                                         pattern_range[i * p[k] + j] = false;
    290                                 pattern_range[i * p[k] + i] = true;
    291                         }
    292                         pattern_jac_r[k] =
    293                                 r_fun[k].RevSparseJac(p[k], pattern_range);
    294                 }
    295         }
    296 
    297         // now compute pattern for fg
    298         BoolVector pattern_jac_fg((m+1) * n);
    299         j = (m+1) * n;
    300         while(j--)
    301                 pattern_jac_fg[j] = false;
    302         for(k = 0; k < K; k++) for(ell = 0; ell < L[k]; ell++)
    303         {       fg_info->index(k, ell, I, J);   
    304                 for(i = 0; i < p[k]; i++)
    305                 {       for(j = 0; j < q[k]; j++)
    306                         {       ir  = i * q[k] + j;
    307                                 ifg = I[i] * n + J[j];
    308                                 pattern_jac_fg[ifg] = ( pattern_jac_fg[ifg]
    309                                                     | pattern_jac_r[k][ir]    );
    310                         }
    311                 }
    312         }
    313         compute_index_jac_g(m, n, pattern_jac_fg, index_jac_g);
    314 }
    315 
    316 // static member function that computes index map from array indices
    317 // for Jacobian of g
    318 void cppad_ipopt_nlp::compute_index_jac_g(
    319         size_t                m              ,
    320         size_t                n              ,
    321         const BoolVector&     pattern_jac_fg ,
    322         IndexMap&             index_jac_g
    323 )
    324 /*
    325 m: input
    326 The number of components in the constraint function g.
    327 
    328 n: input
    329 Number of indpendent variables.
    330 
    331 pattern_jac_fg:
    332 The CppAD sparsity pattern for the Jacobian of g(x).
    333 
    334 index_jac_g:
    335 On input, this is empty; i.e., index_jac_g.size() == 0.
    336 On output, it is the index mapping from (i, j) in the Jacobian of g
    337 to the corresponding values array index in Ipopt.
    338 Furthermore, if index_jac_g[i].find(j) == index_jac_g[i].end(),
    339 then the (i, j) entry in the Jacobian of g is always zero.
    340 */
    341 {       CPPAD_ASSERT_UNKNOWN( index_jac_g.size() == 0 );
    342         index_jac_g.resize(m);
    343         size_t i, j, l = 0;
    344         for(i = 1; i <= m; i++)
    345         {       for(j = 0; j < n; j++)
    346                 {       if( pattern_jac_fg[ i * n + j ] )
    347                                 index_jac_g[i-1][j] = l++;
    348                 }
    349         }
    350 }
    351 
    352 
    353 // static member function that computes CppAD sparsity pattern for
    354 // Hessian of Lagragian
    355 void cppad_ipopt_nlp::compute_index_h_lag(
    356         cppad_ipopt_fg_info  *fg_info        ,
    357         SizeVector&           I              ,
    358         SizeVector&           J              ,
    359         size_t                K              ,
    360         SizeVector&           L              ,
    361         size_t                m              ,
    362         size_t                n              ,
    363         SizeVector&           p              ,
    364         SizeVector&           q              ,
    365         ADFunVector&          r_fun          ,
    366         BoolVectorVector&     pattern_r_lag  ,
    367         IndexMap&             index_h_lag    )
    368 /*
    369 fg_info: input
    370 the cppad_ipopt_fg_info object that is used to compute
    371 information about the representation of fg(x).
    372 
    373 I: scratch space
    374 Vector of length greater than or equal p[k] for all k.
    375 
    376 J: scratch space
    377 Vector of length greatern than or equal q[k] for all k.
    378 
    379 K: input
    380 Number of functions in the representation for fg(x) in terms of r_k (u).
    381 
    382 L: input
    383 L[k] is the number of terms, in the representaiton for fg(x), that use r_k (u).
    384 
    385 m: input
    386 The number of components in the constraint function g.
    387 
    388 n: input
    389 Number of indpendent variables.
    390 
    391 p: input
    392 for k = 0 , ... , K-1,
    393 p[k] is dimension of the range space for r_k (u).
    394 
    395 q: input
    396 for k = 0 , ... , K-1,
    397 p[k] is dimension of the domain space for r_k (u).
    398 
    399 r_fun: input
    400 for k = 0 , ... , K-1,
    401 r_fun[k] is the CppAD function object that is used to compute
    402 the sparsity patterns for r_k (u).
    403 The state of these objects actually changes because some forward mode
    404 routines are used.
    405 The operation sequence correspopnding to these object do not change.
    406 
    407 pattern_r_lag: output
    408 For k = 0 , ... , K-1,
    409 on input pattern_r_lag[k], this must be a vector of length q[k] * q[k].
    410 On output it is the CppAD sparsity pattern for the Hessian of
    411 a Lagragian that sums components of r_k (u).
    412 
    413 index_h_lag:
    414 On input, this is empty; i.e., index_h_lag.size() == 0.
    415 On output, it is the index mapping from (i, j) in the Hessian of the Lagragian
    416 to the corresponding values array index in Ipopt.
    417 Furthermore, if index_h_lag[i].find(j) == index_h_lag[i].end(),
    418 then either i < j or the (i, j) entry in the Hessian of the Lagragian is
    419 always zero.
    420 */
    421 {
    422         size_t i, j, k, ell;
    423 
    424         for(k = 0; k < K; k++)
    425         {       CPPAD_ASSERT_UNKNOWN( pattern_r_lag[k].size() == q[k] * q[k] );
    426                 CPPAD_ASSERT_UNKNOWN( r_fun[k].Range() == p[k] );
    427                 CPPAD_ASSERT_UNKNOWN( r_fun[k].Domain() == q[k] );
    428 
    429                 BoolVector pattern_domain(q[k] * q[k]);
    430                 BoolVector pattern_ones(p[k]);
    431 
    432                 for(i = 0; i < q[k]; i++)
    433                 {       for(j = 0; j < q[k]; j++)
    434                                 pattern_domain[i * q[k] + j] = false;
    435                         pattern_domain[i * q[k] + i] = true;
    436                 }
    437                 r_fun[k].ForSparseJac(q[k], pattern_domain);
    438                 for(i = 0; i < p[k]; i++)
    439                         pattern_ones[i] = true;
    440                 pattern_r_lag[k] = r_fun[k].RevSparseHes(q[k], pattern_ones);
    441         }
    442 
    443         // now compute pattern for fg
    444         BoolVector pattern_h_lag(n * n);
    445         j = (n * n);
    446         while(j--)
    447                 pattern_h_lag[j] = false;
    448         for(k = 0; k < K; k++) for(ell = 0; ell < L[k]; ell++)
    449         {       fg_info->index(k, ell, I, J);
    450                 for(i = 0; i < q[k]; i++)
    451                 {       for(j = 0; j < q[k]; j++)
    452                         {       size_t ir, ifg;
    453                                 ir  = i * q[k] + j;
    454                                 ifg = J[i] * n + J[j];
    455                                 pattern_h_lag[ifg] = ( pattern_h_lag[ifg]
    456                                                     | pattern_r_lag[k][ir]    );
    457                         }
    458                 }
    459         }
    460         compute_index_h_lag(m, n, pattern_h_lag, index_h_lag);
    461 }
    462 
    463 // static member function that computes index map from array indices
    464 // in Hessian of Lagragian
    465 void cppad_ipopt_nlp::compute_index_h_lag(
    466         size_t                m              ,
    467         size_t                n              ,
    468         const BoolVector&     pattern_h_lag  ,
    469         IndexMap&             index_h_lag
    470 )
    471 /*
    472 m: input
    473 The number of components in the constraint function g.
    474 
    475 n: input
    476 Number of indpendent variables.
    477 
    478 pattern_h_lag:
    479 The CppAD sparsity pattern for the Hessian of the Lagragian.
    480 
    481 index_h_lag:
    482 On input, this is empty; i.e., index_h_lag.size() == 0.
    483 On output, it is the index mapping from (i, j) in the Hessian of the Lagragian
    484 to the corresponding values array index in Ipopt.
    485 Furthermore, if index_h_lag[i].find(j) == index_h_lag[i].end(),
    486 then either i < j or the (i, j) entry in the Hessian of the Lagragian is
    487 always zero.
    488 */
    489 {       CPPAD_ASSERT_UNKNOWN( index_h_lag.size() == 0 );
    490         index_h_lag.resize(n);
    491         size_t i, j, l = 0;
    492         for(i = 0; i < n; i++)
    493         {       for(j = 0; j <= i; j++)
    494                 {       if( pattern_h_lag[ i * n + j ] )
    495                                 index_h_lag[i][j] = l++;
    496                 }
    497         }
    498190}
    499191
     
    825517                for(i = 0; i < q_[k]; i++)
    826518                {       for(j = 0; j < q_[k]; j++) if( J_[j] <= J_[i] )
    827                         {       index_ij = index_h_lag_[J_[i]].find(J_[j]);
    828                                 if( index_ij != index_h_lag_[J_[i]].end() )
     519                        {       index_ij = index_hes_fg_[J_[i]].find(J_[j]);
     520                                if( index_ij != index_hes_fg_[J_[i]].end() )
    829521                                {       l          = index_ij->second;
    830522                                        values[l] += r_hes[i * q_[k] + j];
  • trunk/cppad_ipopt/src/cppad_ipopt_nlp.hpp

    r1633 r1634  
    833833        // mapping from array indices to Ipopt sparsity structure
    834834        IndexMap                         index_jac_g_;
    835         IndexMap                         index_h_lag_;
     835        IndexMap                         index_hes_fg_;
    836836        // Ipopt sparsity structure for Hessian of Lagragian
    837837        size_t                           nnz_h_lag_;
     
    856856                ADFunVector&          r_fun
    857857        );
    858         static void compute_index_jac_g(
    859                 cppad_ipopt_fg_info  *fg_info        ,
    860                 SizeVector&           I              ,
    861                 SizeVector&           J              ,
    862                 size_t                K              ,
    863                 SizeVector&           L              ,
    864                 size_t                m              ,
    865                 size_t                n              ,
    866                 SizeVector&           p              ,
    867                 SizeVector&           q              ,
    868                 ADFunVector&          r_fun          ,
    869                 BoolVectorVector&     pattern_jac_r  ,
    870                 IndexMap&             index_jac_g 
    871         );
    872         static void compute_index_h_lag(
    873                 cppad_ipopt_fg_info  *fg_info        ,
    874                 SizeVector&           I              ,
    875                 SizeVector&           J              ,
    876                 size_t                K              ,
    877                 SizeVector&           L              ,
    878                 size_t                m              ,
    879                 size_t                n              ,
    880                 SizeVector&           p              ,
    881                 SizeVector&           q              ,
    882                 ADFunVector&          r_fun          ,
    883                 BoolVectorVector&     pattern_r_lag  ,
    884                 IndexMap&             index_h_hag
    885         );
    886         static void compute_index_jac_g(
    887                 size_t                m              ,
    888                 size_t                n              ,
    889                 const BoolVector&     pattern_jac_fg ,
    890                 IndexMap&             index_jac_g
    891         );
    892         static void compute_index_h_lag(
    893                 size_t                m              ,
    894                 size_t                n              ,
    895                 const BoolVector&     pattern_h_lag  ,
    896                 IndexMap&             index_h_lag
    897         );
    898858
    899859};
  • trunk/cppad_ipopt/test/makefile.am

    r1633 r1634  
    3030                     -I$(IPOPT_DIR)/include
    3131#
    32 LDADD             = -lipopt $(FCLIBS) $(PTHREAD_LIB) $(DL_LIB)
    33 AM_LDFLAGS        = -L$(IPOPT_DIR)/lib
     32LDADD             = -lcppad_ipopt -lipopt $(FCLIBS) $(PTHREAD_LIB) $(DL_LIB)
     33AM_LDFLAGS        = -L../src -L$(IPOPT_DIR)/lib
    3434#
    3535test_SOURCES   = \
    3636        test.cpp \
    37         ../src/cppad_ipopt_nlp.cpp \
    38         ../src/cppad_ipopt_nlp.hpp \
    39         ../src/sparse_map2vec.cpp \
    40         ../src/sparse_map2vec.hpp \
    4137        k_gt_one.cpp \
    4238        multiple_solution.cpp \
  • trunk/cppad_ipopt/test/makefile.in

    r1633 r1634  
    4545CONFIG_CLEAN_VPATH_FILES =
    4646PROGRAMS = $(noinst_PROGRAMS)
    47 am_test_OBJECTS = test.$(OBJEXT) cppad_ipopt_nlp.$(OBJEXT) \
    48         sparse_map2vec.$(OBJEXT) k_gt_one.$(OBJEXT) \
     47am_test_OBJECTS = test.$(OBJEXT) k_gt_one.$(OBJEXT) \
    4948        multiple_solution.$(OBJEXT) retape.$(OBJEXT)
    5049test_OBJECTS = $(am_test_OBJECTS)
     
    6261CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
    6362        -o $@
    64 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
    65         $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
    66 CCLD = $(CC)
    67 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
    6863SOURCES = $(test_SOURCES)
    6964DIST_SOURCES = $(test_SOURCES)
     
    9085CYGPATH_W = @CYGPATH_W@
    9186
    92 # $Id: makefile.am 1632 2010-01-23 12:19:08Z bradbell $
     87# $Id: makefile.am 1633 2010-01-23 14:48:12Z bradbell $
    9388# -----------------------------------------------------------------------------
    9489# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell
     
    200195
    201196#
    202 LDADD = -lipopt $(FCLIBS) $(PTHREAD_LIB) $(DL_LIB)
    203 AM_LDFLAGS = -L$(IPOPT_DIR)/lib
     197LDADD = -lcppad_ipopt -lipopt $(FCLIBS) $(PTHREAD_LIB) $(DL_LIB)
     198AM_LDFLAGS = -L../src -L$(IPOPT_DIR)/lib
    204199#
    205200test_SOURCES = \
    206201        test.cpp \
    207         ../src/cppad_ipopt_nlp.cpp \
    208         ../src/cppad_ipopt_nlp.hpp \
    209         ../src/sparse_map2vec.cpp \
    210         ../src/sparse_map2vec.hpp \
    211202        k_gt_one.cpp \
    212203        multiple_solution.cpp \
     
    260251        -rm -f *.tab.c
    261252
    262 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppad_ipopt_nlp.Po@am__quote@
    263253@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/k_gt_one.Po@am__quote@
    264254@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multiple_solution.Po@am__quote@
    265255@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/retape.Po@am__quote@
    266 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_map2vec.Po@am__quote@
    267256@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test.Po@am__quote@
    268257
     
    280269@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    281270@am__fastdepCXX_FALSE@  $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
    282 
    283 cppad_ipopt_nlp.o: ../src/cppad_ipopt_nlp.cpp
    284 @am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT cppad_ipopt_nlp.o -MD -MP -MF $(DEPDIR)/cppad_ipopt_nlp.Tpo -c -o cppad_ipopt_nlp.o `test -f '../src/cppad_ipopt_nlp.cpp' || echo '$(srcdir)/'`../src/cppad_ipopt_nlp.cpp
    285 @am__fastdepCXX_TRUE@   $(am__mv) $(DEPDIR)/cppad_ipopt_nlp.Tpo $(DEPDIR)/cppad_ipopt_nlp.Po
    286 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../src/cppad_ipopt_nlp.cpp' object='cppad_ipopt_nlp.o' libtool=no @AMDEPBACKSLASH@
    287 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    288 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o cppad_ipopt_nlp.o `test -f '../src/cppad_ipopt_nlp.cpp' || echo '$(srcdir)/'`../src/cppad_ipopt_nlp.cpp
    289 
    290 cppad_ipopt_nlp.obj: ../src/cppad_ipopt_nlp.cpp
    291 @am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT cppad_ipopt_nlp.obj -MD -MP -MF $(DEPDIR)/cppad_ipopt_nlp.Tpo -c -o cppad_ipopt_nlp.obj `if test -f '../src/cppad_ipopt_nlp.cpp'; then $(CYGPATH_W) '../src/cppad_ipopt_nlp.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/cppad_ipopt_nlp.cpp'; fi`
    292 @am__fastdepCXX_TRUE@   $(am__mv) $(DEPDIR)/cppad_ipopt_nlp.Tpo $(DEPDIR)/cppad_ipopt_nlp.Po
    293 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../src/cppad_ipopt_nlp.cpp' object='cppad_ipopt_nlp.obj' libtool=no @AMDEPBACKSLASH@
    294 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    295 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o cppad_ipopt_nlp.obj `if test -f '../src/cppad_ipopt_nlp.cpp'; then $(CYGPATH_W) '../src/cppad_ipopt_nlp.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/cppad_ipopt_nlp.cpp'; fi`
    296 
    297 sparse_map2vec.o: ../src/sparse_map2vec.cpp
    298 @am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sparse_map2vec.o -MD -MP -MF $(DEPDIR)/sparse_map2vec.Tpo -c -o sparse_map2vec.o `test -f '../src/sparse_map2vec.cpp' || echo '$(srcdir)/'`../src/sparse_map2vec.cpp
    299 @am__fastdepCXX_TRUE@   $(am__mv) $(DEPDIR)/sparse_map2vec.Tpo $(DEPDIR)/sparse_map2vec.Po
    300 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../src/sparse_map2vec.cpp' object='sparse_map2vec.o' libtool=no @AMDEPBACKSLASH@
    301 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    302 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sparse_map2vec.o `test -f '../src/sparse_map2vec.cpp' || echo '$(srcdir)/'`../src/sparse_map2vec.cpp
    303 
    304 sparse_map2vec.obj: ../src/sparse_map2vec.cpp
    305 @am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sparse_map2vec.obj -MD -MP -MF $(DEPDIR)/sparse_map2vec.Tpo -c -o sparse_map2vec.obj `if test -f '../src/sparse_map2vec.cpp'; then $(CYGPATH_W) '../src/sparse_map2vec.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/sparse_map2vec.cpp'; fi`
    306 @am__fastdepCXX_TRUE@   $(am__mv) $(DEPDIR)/sparse_map2vec.Tpo $(DEPDIR)/sparse_map2vec.Po
    307 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='../src/sparse_map2vec.cpp' object='sparse_map2vec.obj' libtool=no @AMDEPBACKSLASH@
    308 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    309 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sparse_map2vec.obj `if test -f '../src/sparse_map2vec.cpp'; then $(CYGPATH_W) '../src/sparse_map2vec.cpp'; else $(CYGPATH_W) '$(srcdir)/../src/sparse_map2vec.cpp'; fi`
    310271
    311272ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
  • trunk/makefile.am

    r1633 r1634  
    259259# Did user specify a value for IPOPT_DIR in configure command line
    260260if CppAD_IPOPT_CPPAD
    261 IPOPT_CPPAD = cppad_ipopt/example cppad_ipopt/speed cppad_ipopt/test
     261IPOPT_CPPAD = \
     262        cppad_ipopt/src \
     263        cppad_ipopt/example \
     264        cppad_ipopt/speed \
     265        cppad_ipopt/test
    262266else
    263267IPOPT_CPPAD =
  • trunk/makefile.in

    r1633 r1634  
    4141        $(top_srcdir)/omh/install_unix.omh.in \
    4242        $(top_srcdir)/omh/install_windows.omh.in AUTHORS COPYING \
    43         ChangeLog INSTALL NEWS depcomp install-sh missing
     43        ChangeLog INSTALL NEWS config.guess config.sub depcomp \
     44        install-sh ltmain.sh missing
    4445ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    4546am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     
    9293ETAGS = etags
    9394CTAGS = ctags
    94 DIST_SUBDIRS = cppad_ipopt/example cppad_ipopt/speed cppad_ipopt/test \
    95         example introduction/get_started introduction/exp_apx \
    96         print_for speed/cppad speed/double speed/example speed/profile \
    97         speed/adolc speed/fadbad speed/sacado test_more
     95DIST_SUBDIRS = cppad_ipopt/src cppad_ipopt/example cppad_ipopt/speed \
     96        cppad_ipopt/test example introduction/get_started \
     97        introduction/exp_apx print_for speed/cppad speed/double \
     98        speed/example speed/profile speed/adolc speed/fadbad \
     99        speed/sacado test_more
    98100DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
    99101distdir = $(PACKAGE)-$(VERSION)
     
    236238@CppAD_POSTFIX_FALSE@postfix_dir = .
    237239
    238 # $Id: makefile.am 1628 2010-01-20 15:04:49Z bradbell $
     240# $Id: makefile.am 1633 2010-01-23 14:48:12Z bradbell $
    239241# -----------------------------------------------------------------------------
    240242# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell
     
    473475# ---------------------------------------------------------------
    474476# Did user specify a value for IPOPT_DIR in configure command line
    475 @CppAD_IPOPT_CPPAD_TRUE@IPOPT_CPPAD = cppad_ipopt/example cppad_ipopt/speed cppad_ipopt/test
     477@CppAD_IPOPT_CPPAD_TRUE@IPOPT_CPPAD = \
     478@CppAD_IPOPT_CPPAD_TRUE@        cppad_ipopt/src \
     479@CppAD_IPOPT_CPPAD_TRUE@        cppad_ipopt/example \
     480@CppAD_IPOPT_CPPAD_TRUE@        cppad_ipopt/speed \
     481@CppAD_IPOPT_CPPAD_TRUE@        cppad_ipopt/test
     482
    476483#
    477484SUBDIRS = \
  • trunk/omh/whats_new_10.omh

    r1628 r1634  
    2727The purpose of this section is to
    2828assist you in learning about changes between various versions of CppAD.
     29
     30$head 01-23$$
     31Improve the sparsity patterns and reduce the amount of memory
     32required for large sparse problems using $cref/cppad_ipopt_nlp/$$.
     33The speed test $code cppad_ipopt/speed$$ showed significant improvement.
     34
    2935
    3036$head 01-20$$
  • trunk/test_more/makefile.in

    r1633 r1634  
    123123CYGPATH_W = @CYGPATH_W@
    124124
    125 # $Id: makefile.am 1632 2010-01-23 12:19:08Z bradbell $
     125# $Id: makefile.am 1633 2010-01-23 14:48:12Z bradbell $
    126126# -----------------------------------------------------------------------------
    127127# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell
Note: See TracChangeset for help on using the changeset viewer.