简体   繁体   中英

I want to add lower limit constraints in portfolio optimization in Optaplanner exercise

I want to add lower limit constraints in portfolio optimization in Optaplanner exercise.

In Portfolio optimization in Optaplanner, we can control ratio limit by controlling sector constraints, and can only control upper limit value which is given as Quantity Maximum.

I've tried 'add lower limit as Quantity Minimum, and change Hardscore by quantity minimum similarly as quantity maximum.' However, I failed to apply it.

Anyway, is there any better way to add lower limit constraints in portfolio optimization in Optaplanner?

Plz Help me!

If it's for example per region, just add quantityMillisMinimum field on Region :

public class Region extends AbstractPersistable {

    private String name;
    private Long quantityMillisMaximum; // In milli's (so multiplied by 1000)

    // New field
    private Long quantityMillisMinimum; // In milli's (so multiplied by 1000)
}

and a score rule to add the hard constraint:

// New rule
rule "Region quantity minimum"
    when
        $region : Region($quantityMillisMinimum : quantityMillisMinimum)
        accumulate(
            AssetClassAllocation(region == $region, quantityMillis != null, $quantityMillis : quantityMillis);
            $quantityMillisTotal : sum($quantityMillis);
            $quantityMillisTotal < $quantityMillisMinimum
        )
    then
        scoreHolder.addHardConstraintMatch(kcontext,
                $quantityMillisTotal - $quantityMillisMinimum);
end

Are you using portfolio optimization for anything serious? :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM