Evaluation function for modified knapsack problemForming Dynamic Programming algorithm for a variation of Knapsack ProblemOptimal way of filling 2 knapsacks?Bounded knapsack special case - small individual item weight is small compared to the number of itemsKnapsack algorithm for two bags1/0 Knapsack Variation with Weighted EdgesGetting object list in KnapsackVariant of KnapsackUnderstanding knapsack solutionResource Allocation Optimization - Variation of Multiple KnapsackIs there an algorithm that can solve this variation of the Knapsack Problem?

Incremental Ranges!

Is it legal in the UK for politicians to lie to the public for political gain?

How to skip replacing first occurrence of a character in each line?

Accidentally renamed tar.gz file to a non tar.gz file, will my file be messed up

Did Darth Vader wear the same suit for 20+ years?

Finding x,y coordinates where y is largest

Importance sampling estimation of power function

How would you say “AKA/as in”?

Why don’t airliners have temporary liveries?

How can I instantiate a lambda closure type in C++11/14?

PhD student with mental health issues and bad performance

Does an ice chest packed full of frozen food need ice? 18 day Grand Canyon trip

Does the first version of Linux developed by Linus Torvalds have a GUI?

Is there any word or phrase for negative bearing?

How to supress loops in a digraph?

What is the purpose of building foundations?

C SIGINT signal in Linux

Payment instructions from HomeAway look fishy to me

How bad would a partial hash leak be, realistically?

Who operates delivery flights for commercial airlines?

Why is the relationship between frequency and pitch exponential?

Smooth switching between 12v batteries, with toggle switch

Is the decompression of compressed and encrypted data without decryption also theoretically impossible?

Secure offsite backup, even in the case of hacker root access



Evaluation function for modified knapsack problem


Forming Dynamic Programming algorithm for a variation of Knapsack ProblemOptimal way of filling 2 knapsacks?Bounded knapsack special case - small individual item weight is small compared to the number of itemsKnapsack algorithm for two bags1/0 Knapsack Variation with Weighted EdgesGetting object list in KnapsackVariant of KnapsackUnderstanding knapsack solutionResource Allocation Optimization - Variation of Multiple KnapsackIs there an algorithm that can solve this variation of the Knapsack Problem?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm trying to solve a modified version of the knapsack problem using a hill climbing algorithm, but I can't find a good evaluation function. In this version of the knapsack problem the sum of the weights of all objects in the solution must be equal (not <=) to the knapsack's capacity and the sum of their costs must be maximized.



I've tried several evaluation functions but none of them worked:



  1. I've tried to minimize the expression __abs(sum_of_weights_in_solution - knapsack's capacity)__. Obviously it didn't work because this expression does't take into account the object's costs, but at least it provides a solution which fills the knapsack

  2. I've tried to minimize this expression: __abs(sum_of_weights_in_solution - knapsack's capacity) - sum_of_costs_in_solution__. This one is better but still it doesn't always find the optimal solution even after 10^6 iterations on a knapsack with 10 objects, and I think that's because I can't really treat the cases where the sum of the weights of objects is > than the knapsack's capacity









share|improve this question
























  • This is a rather incomplete description. It's a heuristic, of course a lot can go wrong in terms of your solutions. You did not specify your moves or whatever is being done inbetween evaluations. I don't get your reasoning: your objective treats both directions of error but of course the direction-information is lost in the pure objective. Who knows how you generate your moves. Where does the expectation of reaching a global opt come from? It's a non-convex prob and pure hill-climbing sounds like local-optimization (again related a lot to your moves).

    – sascha
    Mar 24 at 15:53


















0















I'm trying to solve a modified version of the knapsack problem using a hill climbing algorithm, but I can't find a good evaluation function. In this version of the knapsack problem the sum of the weights of all objects in the solution must be equal (not <=) to the knapsack's capacity and the sum of their costs must be maximized.



I've tried several evaluation functions but none of them worked:



  1. I've tried to minimize the expression __abs(sum_of_weights_in_solution - knapsack's capacity)__. Obviously it didn't work because this expression does't take into account the object's costs, but at least it provides a solution which fills the knapsack

  2. I've tried to minimize this expression: __abs(sum_of_weights_in_solution - knapsack's capacity) - sum_of_costs_in_solution__. This one is better but still it doesn't always find the optimal solution even after 10^6 iterations on a knapsack with 10 objects, and I think that's because I can't really treat the cases where the sum of the weights of objects is > than the knapsack's capacity









share|improve this question
























  • This is a rather incomplete description. It's a heuristic, of course a lot can go wrong in terms of your solutions. You did not specify your moves or whatever is being done inbetween evaluations. I don't get your reasoning: your objective treats both directions of error but of course the direction-information is lost in the pure objective. Who knows how you generate your moves. Where does the expectation of reaching a global opt come from? It's a non-convex prob and pure hill-climbing sounds like local-optimization (again related a lot to your moves).

    – sascha
    Mar 24 at 15:53














0












0








0








I'm trying to solve a modified version of the knapsack problem using a hill climbing algorithm, but I can't find a good evaluation function. In this version of the knapsack problem the sum of the weights of all objects in the solution must be equal (not <=) to the knapsack's capacity and the sum of their costs must be maximized.



I've tried several evaluation functions but none of them worked:



  1. I've tried to minimize the expression __abs(sum_of_weights_in_solution - knapsack's capacity)__. Obviously it didn't work because this expression does't take into account the object's costs, but at least it provides a solution which fills the knapsack

  2. I've tried to minimize this expression: __abs(sum_of_weights_in_solution - knapsack's capacity) - sum_of_costs_in_solution__. This one is better but still it doesn't always find the optimal solution even after 10^6 iterations on a knapsack with 10 objects, and I think that's because I can't really treat the cases where the sum of the weights of objects is > than the knapsack's capacity









share|improve this question
















I'm trying to solve a modified version of the knapsack problem using a hill climbing algorithm, but I can't find a good evaluation function. In this version of the knapsack problem the sum of the weights of all objects in the solution must be equal (not <=) to the knapsack's capacity and the sum of their costs must be maximized.



I've tried several evaluation functions but none of them worked:



  1. I've tried to minimize the expression __abs(sum_of_weights_in_solution - knapsack's capacity)__. Obviously it didn't work because this expression does't take into account the object's costs, but at least it provides a solution which fills the knapsack

  2. I've tried to minimize this expression: __abs(sum_of_weights_in_solution - knapsack's capacity) - sum_of_costs_in_solution__. This one is better but still it doesn't always find the optimal solution even after 10^6 iterations on a knapsack with 10 objects, and I think that's because I can't really treat the cases where the sum of the weights of objects is > than the knapsack's capacity






artificial-intelligence knapsack-problem hill-climbing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 14:55









Gilles Heinesch

1,3921824




1,3921824










asked Mar 24 at 14:42









Geo BaditaGeo Badita

11




11












  • This is a rather incomplete description. It's a heuristic, of course a lot can go wrong in terms of your solutions. You did not specify your moves or whatever is being done inbetween evaluations. I don't get your reasoning: your objective treats both directions of error but of course the direction-information is lost in the pure objective. Who knows how you generate your moves. Where does the expectation of reaching a global opt come from? It's a non-convex prob and pure hill-climbing sounds like local-optimization (again related a lot to your moves).

    – sascha
    Mar 24 at 15:53


















  • This is a rather incomplete description. It's a heuristic, of course a lot can go wrong in terms of your solutions. You did not specify your moves or whatever is being done inbetween evaluations. I don't get your reasoning: your objective treats both directions of error but of course the direction-information is lost in the pure objective. Who knows how you generate your moves. Where does the expectation of reaching a global opt come from? It's a non-convex prob and pure hill-climbing sounds like local-optimization (again related a lot to your moves).

    – sascha
    Mar 24 at 15:53

















This is a rather incomplete description. It's a heuristic, of course a lot can go wrong in terms of your solutions. You did not specify your moves or whatever is being done inbetween evaluations. I don't get your reasoning: your objective treats both directions of error but of course the direction-information is lost in the pure objective. Who knows how you generate your moves. Where does the expectation of reaching a global opt come from? It's a non-convex prob and pure hill-climbing sounds like local-optimization (again related a lot to your moves).

– sascha
Mar 24 at 15:53






This is a rather incomplete description. It's a heuristic, of course a lot can go wrong in terms of your solutions. You did not specify your moves or whatever is being done inbetween evaluations. I don't get your reasoning: your objective treats both directions of error but of course the direction-information is lost in the pure objective. Who knows how you generate your moves. Where does the expectation of reaching a global opt come from? It's a non-convex prob and pure hill-climbing sounds like local-optimization (again related a lot to your moves).

– sascha
Mar 24 at 15:53













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%2f55324934%2fevaluation-function-for-modified-knapsack-problem%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















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%2f55324934%2fevaluation-function-for-modified-knapsack-problem%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