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

          How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

          Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?