Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Need to help solving least sparse linear with some known values

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the problem describe below
http://i.stack.imgur.com/RGGum.png
I need to find value of x1', x2', x3', x4', x5' that make

(x1-x1')^2+(x2-x2')^2+(x3-x3')^2+(x4-x4')^2+(x5-x5')^2 = mininum value

and

x1' + x2' + x3' + x4' + x5' = 1

x1 + x2 + x3 + x4 + x5 = 1

Note: we know value of a, b, c, d, e, x1, x2, x3, x4, x5

Would anyone help me in this case?

I have tried with google/or-tools library but can't add condition to find minimum value.

 
Marshal
Posts: 75702
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Always start such problems by working out what the algorithm is: how are you going to calculate it? Once you have the algorithm, the rest of the calculations will usually be easier to code.
 
Saloon Keeper
Posts: 13880
314
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

I'm with Campbell. Don't think about code yet. This is a mathematical problem, and you first need to do the calculations on paper before you can hope to write a line of correct code.

How would you tackle this without a computer?
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic