// File: /workspace/github_cpp_makefile_star2_O3/canzarlab[P]Trajan/geno/augmentedLagrangian.cpp
// Function: AugmentedNLP::AugmentedNLP(GenoNLP&, double, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&)
AugmentedNLP(GenoNLP& genoNLP, Scalar rho, const Vector& y)
    :
    _genoNLP(genoNLP),
    _n(genoNLP.getN()),
    _m(genoNLP.getM()),
    _mEqualities(0),
    _mInequalities(0),
    _constraintValues(Vector(genoNLP.getM())),
//    _jacobian(Matrix(genoNLP.getM(), genoNLP.getN())),
    _rho(rho),
    _y(y),
    _cl(Vector(genoNLP.getM())),
    _cu(Vector(genoNLP.getM())),
    _cType(std::vector<int>(genoNLP.getM())),
    _constraintError(Vector(genoNLP.getM()))
  {
    _genoNLP.getBoundsConstraints(_cl.data(), _cu.data());

    _mEqualities = 0;
    _mInequalities = 0;
    for (Index i = 0; i < _genoNLP.getM(); ++i)
    {
      if (_cl(i) == _cu(i)) {
	_cType[i] = 1;   // equality constraint
	++_mEqualities;
	if (_mInequalities) {
	  std::cout << "Error : Equalitites must precede inequalitites!" 
		    << std::endl;
	  exit(1);
	}
      } else {
	if (_cl(i) != -INF) {
	  _cType[i] = 2;   // has lower bound
	  ++_mInequalities;
	  //	  std::cout << "Error : No lower bounds allowed!"
	  //		    << std::endl;
	  //	  exit(1);
 
	  if ((_cu(i) != INF) && (_cl(i) != _cu(i))) {
	    _cType[i] = 3;
	    //   	    std::cout << "Error : Upper bounds and lower bound are not allowed at the same time!" << std::endl;
		    //	    	    exit(1);
		    //		    		    _cType[i] = 2;
	  }
	}
	if (_cl(i) == -INF) {
	  _cType[i] = 4;      // no lower bound
	  ++_mInequalities;
	}
      }
    }
    //    _s = Vector::Zero(_mInequalities);
    assert(_m = _mEqualities + _mInequalities);
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r12
movsd %xmm0, 0x18(%rsp)
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x753e2(%rip), %rax     # 0x84240
movq %rax, (%rdi)
movq %rsi, 0x8(%rdi)
movq (%rsi), %rax
movq %rsi, %rdi
callq *0x18(%rax)
movq %rax, 0x10(%r15)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
movq %rax, 0x18(%r15)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%r15)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x30(%r15)
testq %rax, %rax
js 0xf0d8
leaq 0x30(%r15), %r14
movl $0x1, %ecx
movq %r14, %rdi
movq %rax, %rsi
movq %rax, %rdx
callq 0xff4c
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x40(%r15)
leaq 0x48(%r15), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %r14, 0x20(%rsp)
callq 0x10120
movq (%rbx), %rax
movq %rbx, %rdi
movq %r13, 0x18(%rsp)
callq *0x20(%rax)
leaq 0x58(%r15), %r12
xorpd %xmm0, %xmm0
movupd %xmm0, (%r12)
testq %rax, %rax
js 0xf0d8
movl $0x1, %ecx
movq %r12, %rdi
movq %rax, %rsi
movq %rax, %rdx
callq 0xff4c
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x68(%r15), %r13
xorpd %xmm0, %xmm0
movupd %xmm0, (%r13)
testq %rax, %rax
js 0xf0d8
movl $0x1, %ecx
movq %r13, %rdi
movq %rax, %rsi
movq %rax, %rdx
callq 0xff4c
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x78(%r15), %rbp
leaq 0x17(%rsp), %rdx
movq %rbp, %rdi
movq %rax, %rsi
callq 0xf480
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x90(%r15), %rbx
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
testq %rax, %rax
js 0xf0d8
movl $0x1, %ecx
movq %rbx, %rdi
movq %rax, %rsi
movq %rax, %rdx
callq 0xff4c
movq 0x8(%r15), %rdi
movq 0x58(%r15), %rsi
movq 0x68(%r15), %rdx
movq (%rdi), %rax
callq *0x30(%rax)
leaq 0x20(%r15), %rax
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
xorl %r14d, %r14d
movq 0x8(%r15), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
cmpq %rax, %r14
jge 0xf06e
cmpq %r14, 0x60(%r15)
jle 0xf08b
cmpq %r14, 0x70(%r15)
jle 0xf08b
movq 0x58(%r15), %rax
movsd (%rax,%r14,8), %xmm0
movq (%r13), %rax
movsd (%rax,%r14,8), %xmm1
ucomisd %xmm1, %xmm0
jne 0xf018
jp 0xf018
movq 0x78(%r15), %rax
movl $0x1, (%rax,%r14,4)
incq 0x20(%r15)
cmpq $0x0, 0x28(%r15)
je 0xf066
jmp 0xf0aa
movsd 0x4d408(%rip), %xmm2    # 0x5c428
ucomisd %xmm0, %xmm2
jae 0xf048
movq 0x78(%r15), %rax
movl $0x2, (%rax,%r14,4)
incq 0x28(%r15)
ucomisd 0x4d3c2(%rip), %xmm1    # 0x5c400
jae 0xf048
movl $0x3, (%rax,%r14,4)
movsd 0x4d3d8(%rip), %xmm1    # 0x5c428
ucomisd %xmm0, %xmm1
jb 0xf066
movq 0x78(%r15), %rax
movl $0x4, (%rax,%r14,4)
incq 0x28(%r15)
incq %r14
jmp 0xefb9
movq 0x28(%r15), %rax
addq 0x20(%r15), %rax
movq %rax, 0x18(%r15)
je 0xf0f7
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4e1b3(%rip), %rdi     # 0x5d245
leaq 0x4e1c9(%rip), %rsi     # 0x5d262
leaq 0x4e1e5(%rip), %rcx     # 0x5d285
movl $0x1a9, %edx            # imm = 0x1A9
callq 0x9200
movq 0x76f0f(%rip), %rdi     # 0x85fc0
leaq 0x4d3a2(%rip), %rsi     # 0x5c45a
movl $0x2f, %edx
callq 0x93b0
movq 0x76ef7(%rip), %rdi     # 0x85fc0
callq 0x9170
movl $0x1, %edi
callq 0x93e0
leaq 0x4db6e(%rip), %rdi     # 0x5cc4d
leaq 0x4dbf1(%rip), %rsi     # 0x5ccd7
leaq 0x4dc0d(%rip), %rcx     # 0x5ccfa
movl $0x138, %edx            # imm = 0x138
callq 0x9200
leaq 0x4d38c(%rip), %rdi     # 0x5c48a
leaq 0x4d3a8(%rip), %rsi     # 0x5c4ad
leaq 0x4d3be(%rip), %rcx     # 0x5c4ca
movl $0x40, %edx
callq 0x9200
jmp 0xf14f
jmp 0xf14f
movq %rax, 0x8(%rsp)
jmp 0xf15c
jmp 0xf125
jmp 0xf125
movq %rax, 0x8(%rsp)
jmp 0xf174
jmp 0xf12e
movq %rax, 0x8(%rsp)
jmp 0xf17d
movq %rax, 0x8(%rsp)
jmp 0xf186
movq %rax, 0x8(%rsp)
jmp 0xf193
movq %rax, 0x8(%rsp)
movq (%r14), %rdi
jmp 0xf19b
jmp 0xf14f
movq %rax, 0x8(%rsp)
movq (%rbx), %rdi
callq 0x93d0
movq (%rbp), %rdi
testq %rdi, %rdi
je 0xf174
movq 0x88(%r15), %rsi
subq %rdi, %rsi
callq 0x9350
movq (%r13), %rdi
callq 0x93d0
movq (%r12), %rdi
callq 0x93d0
movq 0x18(%rsp), %rax
movq (%rax), %rdi
callq 0x93d0
movq 0x20(%rsp), %rax
movq (%rax), %rdi
callq 0x93d0
movq 0x8(%rsp), %rdi
callq 0x9680