Why are the results of cvxpy and cvxopt different?What is the difference between @staticmethod and @classmethod?What is the difference between Python's list methods append and extend?Python join: why is it string.join(list) instead of list.join(string)?Difference between __str__ and __repr__?Why does comparing strings using either '==' or 'is' sometimes produce a different result?What are the differences between type() and isinstance()?Why can't Python parse this JSON data?Importing files from different folderWhy is reading lines from stdin much slower in C++ than Python?Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?

How can a drink contain 1.8 kcal energy while 0 g fat/carbs/protein?

Increasing muscle power without increasing volume

Alphanumeric Line and Curve Counting

Why is Google approaching my VPS machine?

A scene of Jimmy diversity

A Table Representing the altar

At which point can a system be compromised when downloading archived data from an untrusted source?

how slow a car engine can run

Why are there no polls of Tom Steyer yet?

Operation Unz̖̬̜̺̬a͇͖̯͔͉l̟̭g͕̝̼͇͓̪͍o̬̝͍̹̻

How possible is a successful landing just with 1 wing?

Is it rude to refer to janitors as 'floor people'?

What is the word for "event executor"?

What happens if there is no space for entry stamp in the passport for US visa?

Improve quality of image bars

Does the Intel 8085 CPU use real memory addresses?

Should I be able to keep my company purchased standing desk when I leave my job?

Why is Katakana not pronounced Katagana?

Will this tire fail its MOT?

How many bits in the resultant hash will change, if the x bits are changed in its the original input?

How can I obtain a complete list of the kinds of atomic expressions in the Wolfram Language using only the language itself?

Is there an English equivalent for "Les carottes sont cuites", while keeping the vegetable reference?

How Can I Process Untrusted Data Sources Securely?

Is there a typesafe way to get a Database.QueryLocator?



Why are the results of cvxpy and cvxopt different?


What is the difference between @staticmethod and @classmethod?What is the difference between Python's list methods append and extend?Python join: why is it string.join(list) instead of list.join(string)?Difference between __str__ and __repr__?Why does comparing strings using either '==' or 'is' sometimes produce a different result?What are the differences between type() and isinstance()?Why can't Python parse this JSON data?Importing files from different folderWhy is reading lines from stdin much slower in C++ than Python?Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















import numpy as np
import pandas as pd
import cvxpy as cp
import cvxopt
from cvxopt import matrix
G_ = np.load('/shared/FactorBank/temp/G.npy')
h_ = np.load('/shared/FactorBank/temp/h.npy')
q_ = np.load('/shared/FactorBank/temp/q.npy')
N = len(q_)


This is the part of cvxpy.



h = h_.reshape(len(h_))
A = np.ones((1, N))
b = np.ones(1)
x = cp.Variable(int(N))
obj = cp.sum(q_ * x)
#print(G_)
constraints = [G_ * x <= h, A * x == b]
prob = cp.Problem(cp.Minimize(obj), constraints)
prob.solve()
print "status:", prob.status
print "optimal value", prob.value
print "optimal var", x.value


status: optimal



optimal value -3.598688474475655



optimal var [ 1.45281688e-05 1.21958458e-05 -2.80709993e-04 ... -1.77801870e-04
-2.01577984e-04 -1.12303384e-04]



This is the part of cvxopt.



G = matrix(G_)
h = matrix(h_)
A = matrix(1.0, (1, N))
b = matrix(1.0)
q = matrix(q_.T)
portfolios = cvxopt.solvers.lp(q, G, h, A, b)


pcost dcost gap pres dres k/t



0: 2.8090e-02 -3.1698e+02 2e+04 2e-01 5e-09 1e+00



1: -6.1531e+01 -9.3943e+01 2e+03 2e-02 6e-10 2e-02



2: -2.7578e+01 -3.3144e+01 1e+02 3e-03 1e-10 2e-02



3: -1.8330e+01 -2.1642e+01 7e+01 2e-03 6e-11 1e-02



……



22: -2.4301e+00 -2.4301e+00 5e-06 1e-10 3e-11 7e-10



23: -2.4301e+00 -2.4301e+00 8e-08 2e-12 1e-09 1e-11
Optimal solution found.



So does anyone know although the status are both "optimal", why the results are not the same?










share|improve this question




























    3















    import numpy as np
    import pandas as pd
    import cvxpy as cp
    import cvxopt
    from cvxopt import matrix
    G_ = np.load('/shared/FactorBank/temp/G.npy')
    h_ = np.load('/shared/FactorBank/temp/h.npy')
    q_ = np.load('/shared/FactorBank/temp/q.npy')
    N = len(q_)


    This is the part of cvxpy.



    h = h_.reshape(len(h_))
    A = np.ones((1, N))
    b = np.ones(1)
    x = cp.Variable(int(N))
    obj = cp.sum(q_ * x)
    #print(G_)
    constraints = [G_ * x <= h, A * x == b]
    prob = cp.Problem(cp.Minimize(obj), constraints)
    prob.solve()
    print "status:", prob.status
    print "optimal value", prob.value
    print "optimal var", x.value


    status: optimal



    optimal value -3.598688474475655



    optimal var [ 1.45281688e-05 1.21958458e-05 -2.80709993e-04 ... -1.77801870e-04
    -2.01577984e-04 -1.12303384e-04]



    This is the part of cvxopt.



    G = matrix(G_)
    h = matrix(h_)
    A = matrix(1.0, (1, N))
    b = matrix(1.0)
    q = matrix(q_.T)
    portfolios = cvxopt.solvers.lp(q, G, h, A, b)


    pcost dcost gap pres dres k/t



    0: 2.8090e-02 -3.1698e+02 2e+04 2e-01 5e-09 1e+00



    1: -6.1531e+01 -9.3943e+01 2e+03 2e-02 6e-10 2e-02



    2: -2.7578e+01 -3.3144e+01 1e+02 3e-03 1e-10 2e-02



    3: -1.8330e+01 -2.1642e+01 7e+01 2e-03 6e-11 1e-02



    ……



    22: -2.4301e+00 -2.4301e+00 5e-06 1e-10 3e-11 7e-10



    23: -2.4301e+00 -2.4301e+00 8e-08 2e-12 1e-09 1e-11
    Optimal solution found.



    So does anyone know although the status are both "optimal", why the results are not the same?










    share|improve this question
























      3












      3








      3








      import numpy as np
      import pandas as pd
      import cvxpy as cp
      import cvxopt
      from cvxopt import matrix
      G_ = np.load('/shared/FactorBank/temp/G.npy')
      h_ = np.load('/shared/FactorBank/temp/h.npy')
      q_ = np.load('/shared/FactorBank/temp/q.npy')
      N = len(q_)


      This is the part of cvxpy.



      h = h_.reshape(len(h_))
      A = np.ones((1, N))
      b = np.ones(1)
      x = cp.Variable(int(N))
      obj = cp.sum(q_ * x)
      #print(G_)
      constraints = [G_ * x <= h, A * x == b]
      prob = cp.Problem(cp.Minimize(obj), constraints)
      prob.solve()
      print "status:", prob.status
      print "optimal value", prob.value
      print "optimal var", x.value


      status: optimal



      optimal value -3.598688474475655



      optimal var [ 1.45281688e-05 1.21958458e-05 -2.80709993e-04 ... -1.77801870e-04
      -2.01577984e-04 -1.12303384e-04]



      This is the part of cvxopt.



      G = matrix(G_)
      h = matrix(h_)
      A = matrix(1.0, (1, N))
      b = matrix(1.0)
      q = matrix(q_.T)
      portfolios = cvxopt.solvers.lp(q, G, h, A, b)


      pcost dcost gap pres dres k/t



      0: 2.8090e-02 -3.1698e+02 2e+04 2e-01 5e-09 1e+00



      1: -6.1531e+01 -9.3943e+01 2e+03 2e-02 6e-10 2e-02



      2: -2.7578e+01 -3.3144e+01 1e+02 3e-03 1e-10 2e-02



      3: -1.8330e+01 -2.1642e+01 7e+01 2e-03 6e-11 1e-02



      ……



      22: -2.4301e+00 -2.4301e+00 5e-06 1e-10 3e-11 7e-10



      23: -2.4301e+00 -2.4301e+00 8e-08 2e-12 1e-09 1e-11
      Optimal solution found.



      So does anyone know although the status are both "optimal", why the results are not the same?










      share|improve this question














      import numpy as np
      import pandas as pd
      import cvxpy as cp
      import cvxopt
      from cvxopt import matrix
      G_ = np.load('/shared/FactorBank/temp/G.npy')
      h_ = np.load('/shared/FactorBank/temp/h.npy')
      q_ = np.load('/shared/FactorBank/temp/q.npy')
      N = len(q_)


      This is the part of cvxpy.



      h = h_.reshape(len(h_))
      A = np.ones((1, N))
      b = np.ones(1)
      x = cp.Variable(int(N))
      obj = cp.sum(q_ * x)
      #print(G_)
      constraints = [G_ * x <= h, A * x == b]
      prob = cp.Problem(cp.Minimize(obj), constraints)
      prob.solve()
      print "status:", prob.status
      print "optimal value", prob.value
      print "optimal var", x.value


      status: optimal



      optimal value -3.598688474475655



      optimal var [ 1.45281688e-05 1.21958458e-05 -2.80709993e-04 ... -1.77801870e-04
      -2.01577984e-04 -1.12303384e-04]



      This is the part of cvxopt.



      G = matrix(G_)
      h = matrix(h_)
      A = matrix(1.0, (1, N))
      b = matrix(1.0)
      q = matrix(q_.T)
      portfolios = cvxopt.solvers.lp(q, G, h, A, b)


      pcost dcost gap pres dres k/t



      0: 2.8090e-02 -3.1698e+02 2e+04 2e-01 5e-09 1e+00



      1: -6.1531e+01 -9.3943e+01 2e+03 2e-02 6e-10 2e-02



      2: -2.7578e+01 -3.3144e+01 1e+02 3e-03 1e-10 2e-02



      3: -1.8330e+01 -2.1642e+01 7e+01 2e-03 6e-11 1e-02



      ……



      22: -2.4301e+00 -2.4301e+00 5e-06 1e-10 3e-11 7e-10



      23: -2.4301e+00 -2.4301e+00 8e-08 2e-12 1e-09 1e-11
      Optimal solution found.



      So does anyone know although the status are both "optimal", why the results are not the same?







      python






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 26 at 9:08









      ArianaAriana

      161 bronze badge




      161 bronze badge






















          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55353340%2fwhy-are-the-results-of-cvxpy-and-cvxopt-different%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55353340%2fwhy-are-the-results-of-cvxpy-and-cvxopt-different%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript