package MpmasConstraintInfoEdicMatlab;

use strict;
use warnings;
use Exporter;
use Storable qw(dclone);
use Data::Dumper;
use MpmasInputfile;
use MpmasInputBlock;
our @ISA = qw(MpmasInputfile);

sub filename {
	return "ConstraintInfoEdicMatlab";
}

sub extension {
	return ".txt";
}
sub leftmargin {
	return "";
}
sub prepare_special {
	my $self = shift;
	my $cinfo = MpmasInputBlock->new(0,10);
	my %ctn;
	for my $n ($self->networkobjects) {

		$ctn{$n->con} = $n->id;
	}

	my @SortedConstraintGroupings = sort{$a cmp $b} keys %{$self->config_entry("Groupings")->{constraint}};
	$cinfo->add_row("OutfileCol","Name", "Costs", "Units");
	for my $k ($self->sorted_constraints) {
		my $i = $self->constraint($k);
		my $col = $i->lp_row + 15;
		my $cost = 0;
		my $units = 1;
		if (exists $ctn{$i->lp_row} ) {

			my $no = $self->networkobject($ctn{$i->lp_row});
			$cost = $no->attr("acqcost");
			$units =  $no->attr("multiplier") ;
		}
		my @temp = ($col, $i->attr("name"), $cost, $units);	

		$cinfo->add_row(@temp);
	}
	$self->add_block($cinfo);

}
1;
