예제 #1
0
파일: amplpy.py 프로젝트: b45ch1/nlpy
 def irow(self, i):
     """
     Evaluate sparse gradient of the linear part of the
     i-th constraint. Useful to obtain constraint rows
     when problem is a linear programming problem.
     """
     try:
         sri_dict = _amplpy.eval_row(i)
     except:
         raise RunTimeError, "Failed to fetch sparse row"
         return None
     sri = sv.SparseVector(self.n, sri_dict)
     return sri
예제 #2
0
 def irow(self, i):
     """
     Evaluate sparse gradient of the linear part of the
     i-th constraint. Useful to obtain constraint rows
     when problem is a linear programming problem.
     """
     try:
         sri_dict = self.model.eval_row(i)
     except:
         raise RuntimeError, "Failed to fetch sparse row"
         return None
     sri = sv.SparseVector(self.n, sri_dict)
     if self.scale_con is not None: sri *= self.scale_con[i]
     return sri
예제 #3
0
파일: amplpy.py 프로젝트: b45ch1/nlpy
 def sigrad(self, i, x):
     """
     Evaluate sparse gradient of i-th constraint at x.
     Returns a sparse vector representing the sparse gradient
     in coordinate format.
     """
     try:
         sci_dict = _amplpy.eval_sgi(i, x)
     except:
         raise RunTimeError, "Failed to fetch sparse constraint gradient"
         return None
     self.Jeval += 1
     sci = sv.SparseVector(self.n, sci_dict)
     return sci
예제 #4
0
 def sigrad(self, i, x):
     """
     Evaluate sparse gradient of i-th constraint at x.
     Returns a sparse vector representing the sparse gradient
     in coordinate format.
     """
     try:
         sci_dict = self.model.eval_sgi(i, x)
     except:
         raise RuntimeError, "Failed to fetch sparse constraint gradient"
         return None
     self.Jeval += 1
     sci = sv.SparseVector(self.n, sci_dict)
     if self.scale_con is not None: sci *= self.scale_con[i]
     return sci
예제 #5
0
파일: amplpy.py 프로젝트: b45ch1/nlpy
 def cost(self):
     """
     Evaluate sparse cost vector.
     Useful when problem is a linear program.
     Return a sparse vector. This method changes the sign of the cost vector
     if the problem is a maximization problem.
     """
     try:
         sc_dict = _amplpy.eval_cost()
     except:
         raise RunTimeError, "Failed to fetch sparse cost vector"
         return None
     sc = sv.SparseVector(self.n, sc_dict)
     if not self.minimize: sc *= -1
     return sc
예제 #6
0
파일: amplpy.py 프로젝트: b45ch1/nlpy
 def sgrad(self, x):
     """
     Evaluate sparse objective gradient at x.
     Returns a sparse vector. This method changes the sign of the objective
     gradient if the problem is a maximization problem.
     """
     try:
         sg_dict = _amplpy.eval_sgrad(x)
     except:
         raise RunTimeError, "Failed to fetch sparse gradient of objective"
         return None
     self.geval += 1
     sg = sv.SparseVector(self.n, sg_dict)
     if not self.minimize: sg *= -1
     return sg